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.....:)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.