in reply to Re: Perl Newbie
in thread Perl Newbie

Hi, thank you for the reply, but perhaps my question was malformed, I try to be more clear: With that script everything goes well except the return of the date inside the tag <date>...</date> I presume that the problem is in this subfunction I replicated from the subfunction that try to get the Title of the page:
# this first bit is right out of the HTML::Parser perldoc sub title_handler { return if shift ne "title"; my $self = shift; $self->handler( text => sub { $j::title = shift }, "dtext" ); $self->handler( end => sub { shift->eof if shift eq "title"; }, "tagname,self" ); } sub date_handler { return if shift ne "date"; my $self = shift; $self->handler( text => sub { $j::date = shift }, "dtext" ); $self->handler( end => sub { shift->eof if shift eq "date"; }, "tagname,self" ); }
And then when I call it:
sub insertFile { my $file = shift; my $p = HTML::Parser->new( api_version => 3 ); $p->handler( start => \&title_handler, "tagname,self" ); $p->handler( start => \&date_handler, "tagname,self" ); $p->parse_file($file); .................
If I delete the call to date, the Title subfunction goes well, but I lost the date, on the other side if I left everything as I modified, the date goes well but I lost the Title. I hope that now is more clear.....:)

Replies are listed 'Best First'.
Re^3: Perl Newbie
by aitap (Curate) on Aug 28, 2012 at 09:28 UTC
    Try running your code in the debugger. Does the $j::date variable get assigned? Perhaps you need it to look like the old one (I mean, the same format, try Date::Parse and strftime("%F %T",str2time($j::date))).
    Sorry if my advice was wrong.