H
Himanshu Garg
Hello,
I am using HTML:
arser and want to know the line number where a
particular event occurs. Given below is an illustrative example :-
-----------------------------------------------------------
use strict;
use HTML:
arser;
# Create parser object
my $p = HTML:
arser->new( api_version => 3,
start_h => [\&start, "tagname"],
);
$p->report_tags("s"); # report only s event
$p->parse_file(*STDIN);
sub start
{
warn "<s> found in $."; # HOW TO PRINT THE LINE NUMBER
}
----------------------------------------------------------------
Although warn normally prints the input file line number on its own,
here it doesn't do that when I print it explicitly (using $.). I get
the following error message :-
Use of uninitialized value in concatenation (.) or string at
../parsehtml.pl line
Could you suggest the right ways of getting the line number, please.
The input I am parsing is erroneous and I want to know the location of
errors. Hence the above code.
Thank You
Himanshu.
I am using HTML:
particular event occurs. Given below is an illustrative example :-
-----------------------------------------------------------
use strict;
use HTML:
# Create parser object
my $p = HTML:
start_h => [\&start, "tagname"],
);
$p->report_tags("s"); # report only s event
$p->parse_file(*STDIN);
sub start
{
warn "<s> found in $."; # HOW TO PRINT THE LINE NUMBER
}
----------------------------------------------------------------
Although warn normally prints the input file line number on its own,
here it doesn't do that when I print it explicitly (using $.). I get
the following error message :-
Use of uninitialized value in concatenation (.) or string at
../parsehtml.pl line
Could you suggest the right ways of getting the line number, please.
The input I am parsing is erroneous and I want to know the location of
errors. Hence the above code.
Thank You
Himanshu.