in reply to Re: Re: Count number of lines?
in thread Count number of lines?
For those of you who wondered, as I did, here's what perl -lpe '}{$_="$.users to date"' is doing:
The -p option wraps your code in the following loop (see perlrun):
LINE:
while (<>) {
... # your program goes here
} continue {
print or die "-p destination: $!\n";
}
The code supplied with the -e switch inserts a closing curly brace, creating an empty while BLOCK, followed by an opening curly brace, which makes a bare block after the while block.
LINE:
while (<>) { }
{ $_="$. users to date" }
continue {
print or die "-p destination: $!\n";
}
The while loop reads all the input records, the bare block assigns the string including the value of the input record counter to $_, and the continue block prints the string.
|
|---|