Next | February 2001 | Slide #51 |
package GetLinks; use HTML::Parser; @ISA = qw(HTML::Parser);
sub start { my ($self, $tagname, $attr, $attrseq, $origtext) = @_; if ($tagname eq 'a' && exists $attr->{href}) { push @{$self->{links}}, $attr->{href}; } }
To use GetLinks:
use GetLinks; my $parser = GetLinks->new; $parser->parse_file('file.html'); # inherited method my @links = @{$parser->{links}};
Next | ![]() |
Copyright © 2001 M-J. Dominus |