Print Line number as script runs..

J

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 = "<some magic variable>";
print " CURRENT LINE: \"$line\"\n";
exit;
#########


Joe
 
G

Gunnar Hjalmarsson

Joe said:
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".
 
J

Joe

You seem to be looking for __LINE__


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..
 
B

brian d foy

Joe said:
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 :)
 
J

jl_post

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top