wrote:
> If I "die" a script, Perl tells me which line number it died on. So, I
> presume, Perl is keeping track of that somehow.
>
> I'm developing a script that is logging diagnostic messages. I would
> like to include the line number that the message was logged from. I
> thought I might find a "special character" such as $. that stores the
> current line being executed... but, alas, I didn't spot such a special
> character in my quickref.
>
> Perl seems to "know" what line it's processing (because of the behavior
> of 'die'). Can I access this bit of information?
In addition to Anno's tips, you might do well to keep in mind that,
like die(), warn() will also report the file and line number (provided
you don't end its argument list with a newline):
warn "Diag message: Count = $count";
will print to STDERR: "Diag message: Count = 42 at file.pl line 28"
Paul Lalli