Print Line number as script runs..

Print Line number as script runs..

am 19.11.2007 02:39:55 von joe

All,

Is there a special variable for current line number as the script
runs?
Using this for debugging as script is executed..

maybe append this with "die" or "warn" to give me a line number.

ex.

#########
/usr/bin/perl -w
use strict;
my $line = "";
print " CURRENT LINE: \"$line\"\n";
exit;
#########


Joe

Re: Print Line number as script runs..

am 19.11.2007 02:48:26 von Gunnar Hjalmarsson

Joe wrote:
> Is there a special variable for current line number as the script
> runs?
> Using this for debugging as script is executed..

You seem to be looking for __LINE__

> maybe append this with "die" or "warn" to give me a line number.

die() and warn() print the line number if the last string you pass to
them does not end with "\n".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Re: Print Line number as script runs..

am 19.11.2007 03:37:06 von joe

On Mon, 19 Nov 2007 02:48:26 +0100, Gunnar Hjalmarsson
wrote:

>Joe wrote:
>> Is there a special variable for current line number as the script
>> runs?
>> Using this for debugging as script is executed..
>
>You seem to be looking for __LINE__
>
>> maybe append this with "die" or "warn" to give me a line number.
>
>die() and warn() print the line number if the last string you pass to
>them does not end with "\n".


Thanks..

I have a few scripts over 15000 lines.. Here recently it's starting to
poke it's head..

Re: Print Line number as script runs..

am 20.11.2007 03:16:22 von brian d foy

In article , Joe
wrote:

> All,
>
> Is there a special variable for current line number as the script
> runs?
> Using this for debugging as script is executed..

You want something like Devel::Trace, which prints out each line before
it's executed. Instead of printing each line, however, modify the
source to print out the line number.

See my article on creating Perl debuggers:

http://www.ddj.com/184404522

or check out the stuff on the DB::* namespace in perldebug.

Good luck :)

Re: Print Line number as script runs..

am 20.11.2007 20:26:21 von jl_post

On Nov 19, 7:16 pm, brian d foy wrote:
>
> See my article on creating Perl debuggers:
>
> http://www.ddj.com/184404522


Thank-you for sharing that. I found it really useful.

I never knew about "ptkdb" before now. Now I can debug my programs
graphically with "perl -d:ptkdb script.pl" on my ActiveState Perl
distribution (provided I first install ptkdb with "ppm install Devel-
ptkdb").

Thanks again, brian.

-- Jean-Luc Romano