getting line number from perl interpreter?
I have a perl program that provides a bunch of functions that
basically implements a little language. The "data files" are themselves
perl that make calls to the functions provided in the
"main" program. How can I structure the main program and the evaluation of
the data file such that when I encounter an error
in the data file I can print what line number it occurred on? The trick is
that the data files are truly perl: I'd have to parse
perl to find the line numbers associated with a particular function call,
and I've heard over and over again that "perl is best at
parsing perl". OK, so how can I do this?
Currently I'm doing something like this:
if ($arg eq "error")
print("error!\n"); # at what data file line number, though?
print ("good input\n");
$cmd .= $_;
% main.pl < data.pl
(I actually do an "open" of the data file and read it in via the file
handle from within main.pl, but this shows the idea).
The data files are fully perl-ized and free-form:
simple tricks like counting carriage returns or ");" won't work -- surely
the line number in the internal interpreter must be available somewhere (if
I do the evaluation differently? How?) since perl
issues line numbers for perl errors!
thanks for any help!
Get Your Private, Free E-mail from MSN Hotmail at http://www.*-*-*.com/