Click to See Complete Forum and Search --> : Line numbers


Charles
09-09-2004, 06:57 PM
Ever have one of those moments when you just can't remember something you know?

How does one use a comment to change line numbering?

Jeff Mott
09-09-2004, 07:41 PM
A comment to change line numbering? So... this is for the line numbering of your Perl script file? Or the line numbering of some file you're reading? Sorry, I'm not quite sure what you're asking.

Charles
09-10-2004, 05:49 AM
Perl's internal tracking of which line of your code it's working on. The line number that the compiler returns when it hits a syntax error or that the "die" function returns. It looks something like:

#line:7

I'm working on a script embeded in a batch file. The compiler reports the line numbers from the shebang and I'm too lazy to add the offset from the top of the page.

Charles
09-10-2004, 10:16 AM
I may have found it: http://www.unix.org.ua/orelly/perl/prog3/ch24_05.htm#ch24-sect-gen .

silent11
09-10-2004, 01:15 PM
print __LINE__;

Camel book, page 993

Charles
09-10-2004, 04:06 PM
I don't want to print out the line number; I want to change the numbering to make debugging a little easier. The following MSDOS batch file will show you what I'm up to. My memory was just a little off.

@echo off
perl -x -S "%0"
goto end

#!c:/perl/bin/perl.exe -w
# line 7

print "Hello, World!\n";
die;

__END__
:end

Jeff Mott
09-13-2004, 09:04 AM
Hmm, I still can't find it within perldoc. The site your referenced makes it sound as though you need the C preprocessor for this to work, but I've found that you don't actually need to set any of Perl's switches. :confused:

Charles
09-13-2004, 10:33 AM
I know, but it's working nonetheless.