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.
In reply to Re: Re: Re: Count number of lines?
by converter
in thread Count number of lines?
by ginocapelli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |