Thread Code für HTML::Parser korrekt?
(19 answers)
Opened by Gast at 2010-03-01 19:48
Was stimmt hier nicht? (Use of uninitialized value $text)
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 $parser->handler( start => \&start_handler, 'tagname, self' ); $parser->parse( $content ); sub start_handler { return if shift ne 'li'; my $self = shift; $self->handler( start => \&title_handler, 'tagname, attr, self' ); } sub title_handler { my( $tagname, $attr, $self ) = @_; return if $tagname ne 'a'; return unless $attr->{title}; my $text; $self->handler( text => sub{ $text = shift; }, 'dtext' ); say "$text: $attr->{href}"; # Use of uninitialized value $text in concatenation (.) or string } |