Hi all,
I've started to get acquinted with Perl's HTML::Parser, which does a really good job at parsing html (duh ;-)
But for the life of me, I can't get it to return the actual text from subroutine! I keep getting references to it :\ :\
use HTML::Parser;
package MyParser;
sub start {
my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
if ($tagname eq 'img') {
my $Title=$attr->{ title };
# now this works well, and actually prints the value and not the reference!
print "Image title found: ", $attr->{ title }, "\n";
return($Title);
} else {return();}
}
my $parser = MyParser->new;
my $html="<img src='blah.jpg' title='hi!'>";
my $title;
$title= $parser -> parse($partial_html);
print "title is: $title\n"
# ------ OUTPUT -----
# Image title found: hi!
# title is: MyParser=HASH(0x9d2f40)
Can anyone explain to me what I am doing wrong? (Or how to correctly return values from the subroutine?)
Thanks a bunch! Blessed be those who answer! :)
-FH