File Coverage

lib/App/ExtractLinks.pm
Criterion Covered Total %
statement 10 19 52.6
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 0 2 0.0
total 14 29 48.2


line stmt bran cond sub pod time code
1             package App::ExtractLinks;
2              
3             # ABSTRACT: extract href's in HTML docs to stdout
4              
5 2     2   62851 use strict;
  2         6  
  2         68  
6 2     2   14 use warnings;
  2         4  
  2         74  
7              
8 2     2   1141 use HTML::Parser;
  2         15215  
  2         145  
9              
10             our $VERSION;
11              
12             BEGIN {
13 2     2   353 $VERSION = '0.0.2';
14             }
15              
16             my $parser = HTML::Parser->new(api_version => 3);
17              
18             sub handler {
19 0     0 0   my $attr = shift;
20              
21 0           foreach my $key (keys %$attr) {
22 0           my $val = %$attr{$key};
23              
24 0 0         if ($key eq 'href') {
25 0           print "$val\n";
26             }
27             }
28             }
29              
30             sub run {
31 0     0 0   $parser->handler(start => \&handler, 'attr');
32              
33 0           while (<>) {
34 0           $parser->parse($_);
35             }
36              
37 0           $parser->eof;
38             }
39              
40             1;
41              
42             =head1 NAME
43              
44             ExtractLinks
45              
46             =head1 DESCRIPTION
47              
48             Extract hrefs from HTML documents to stdout.
49