$p->handler( start => \&a_start_handler, "tagname,self,attr" ); $p->unbroken_text( 1 ); $p->parse( $content ) || die $!; foreach my $link ( @linklist ){ print $link->[0]; #link print $link->[1]; #text } sub a_start_handler { my( $tag, $self, $attr ) = @_; # we only act on {href} ) ){ $self->handler(text => sub { $text = shift; $text =~ s/\n//g; },"dtext"); $self->handler( end => \&a_end_handler, "tagname,self" ); } foreach my $key ( keys %$attr ){ # print ">$key=$attr->{$key}\n"; } } sub a_end_handler { return if shift ne "a"; my $self = shift; push @linklist, [ $href, $text ] if defined $text && $text !~ /^\s*$/; $self->handler(end => undef ); $self->handler(text => undef ); } #### $self->handler(text => sub { $text = shift; $text =~ s/\n//g; },"dtext"); #### $self->handler( text => sub { $text = shift; $text =~ s/\n//g; },"text");