in reply to Display Line Numbers

You may be talking about line numbers in a text editor used to edit Perl scripts. If that's the case, you're asking a broad question because we have no idea what code editor you're using (and since it's not a Perl topic we probably don't much care).

Or you may be asking how to determine what line number you've just read out of a file. If that's the case, the "$." special variable will tell you what line number you're reading. See perlvar for details.

Or you may be asking how to determine what line in your script is currently executing. If that's the case, the __LINE__ tag will tell you. You can print __LINE__, "\n";, for example. See perldata for details about the __LINE__ "Special Literal".

Or if you just want to know how many lines there are in a file.... well, here's a Perl solution:

perl -n -e "END { print $., "\n"; }" file.txt


Dave

Replies are listed 'Best First'.
Re: Re: Display Line Numbers
by TekWannaBe (Initiate) on Jan 30, 2004 at 18:26 UTC
    I am using VI on a unix box using Perl 5.x.... I thought there were a means of displaying the line numbers in your code. Maybe this is not a perl question at all. I do apologize but sincerely appreciate the responses. Thanks,

      In addition to the responses that you've already received, if you use vi to edit, then you should use the '+n' argument from the command line to put you directly to that line of the source file. Alternatively, while inside vi, type ':n' to go to line n in the file.

      And no, that wasn't a Perl question. The next time you have a vi question, read the man page or buy the O'Reilly book.

      Alex / talexb / Toronto

      Life is short: get busy!

        Thanks, actually I did a set number according to the reference manual. You guy'z are awesome!