Folschette wrote:
> hello,
> is there a veriable holding the total amount of lines of a specific file ?
> or do I have to count the lines in a loop?
>
> christophe folschette
[trwww@devel_rh trwww]$ perl -e 'print($., "\n") while (<>);' < mbox
1
2
3
...
from perldoc perlvar
$INPUT_LINE_NUMBER
$NR
$. The current input record number for the last file
handle from which you just read() (or called a
"seek" or "tell" on). The value may be different
from the actual physical line number in the file,
depending on what notion of "line" is in
effect--see $/ on how to change that. An explicit
close on a filehandle resets the line number.
Because "<>" never does an explicit close, line
numbers increase across ARGV files (but see exam
ples in "eof" in perlfunc). Consider this vari
able read-only: setting it does not reposition the
seek pointer; you'll have to do that on your own.
Localizing $. has the effect of also localizing
Perl's notion of "the last read filehandle".
(Mnemonic: many programs use "." to mean the cur
rent line number.)
Todd W
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]