BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
Never mind: -nl autochomps!
When I run this:
S:\>perl.exe -nle"1+index($_, 'clanks') and print" 8gb.txt | wc -l 2048
It reports 2048 hits, which is the same as grep finds:
S:\>grep -F clanks 8gb.txt | wc -l 2048
But when I run this:
S:\>perl -le"while(<>){ 1+index($_, 'clanks') and print; }" 8gb.txt | +wc -l 4096
The number of hits doubles. Can you see why?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO mystery (Solved!)
by afoken (Chancellor) on Jun 28, 2015 at 18:51 UTC | |
by BrowserUk (Patriarch) on Jun 28, 2015 at 19:06 UTC | |
by afoken (Chancellor) on Jun 28, 2015 at 21:35 UTC |