in reply to Re: Question on Reading a file inside while and counting no.of lines
in thread Question on Reading a file inside while and counting no.of lines
It starts at zero…
Actually, it starts at 1, not 0.
C:\strawberry>perl -nE "say $." README.txt | head 1 2 3 4 5 6 7 8 9 10 C:\strawberry>
It's probably also worth demonstrating here the usual idiom for resetting the line number to 1 for each file in @ARGV when using <>.
# @ARGV may have more than one file in it while (<ARGV>) { print "$.:$_\n"; } continue { close ARGV if eof; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question on Reading a file inside while and counting no.of lines
by davido (Cardinal) on Jun 16, 2013 at 06:50 UTC | |
|
Re^3: Question on Reading a file inside while and counting no.of lines
by AnomalousMonk (Archbishop) on Jun 16, 2013 at 22:33 UTC | |
by Jim (Curate) on Jun 17, 2013 at 14:56 UTC |