Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have written the following code which successfully grabs some text representing a date, which is embedded inside a form as a subtitle

my $reportdate; my $tp = HTML::TokeParser->new($sourcefile) or die "Unable to open meg +.out: $!"; #The report date is embedded inside a form as a subtitle. #Therefore, find the form called calendarForm and then look #for a <td> tag which contains the date while (my $tag = $tp->get_tag("form")) { my ($tagname, $attr, $attrseq, $rawtxt) = @{ $tag }; if ($rawtxt =~ /calendarForm/) { while ( my $tag = $tp->get_tag("td")) { my ($tagname, $attr, $attrseq, $rawtxt) = @{ $tag }; if ($rawtxt =~ /subTitle/) { $reportdate = $tp->get_trimmed_text("/td"); print "report date =" . $reportdate . "\n"; last; } } } }

Then I switched each occurance of my ($tagname, $attr, $attrseq, $rawtxt) = @{ $tag }; with my $rawtxt = pop @{ $tag };, expecting it to work similarly, but did see the date printed out. However, the script did not fail, and executed code furhter below.

Can you explain why the pop doesn't work?

Replies are listed 'Best First'.
Re: HTML::TokeParser question
by Anonymous Monk on Jul 15, 2005 at 18:24 UTC

    Hi again, I'm the author of the question

    Nevermind the question! I had 'accidentally' removed the print statment! TGIF!!!!