perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
Why didn't this work:
A correct solution (that takes the same time?)time perl -e '$_=[];{$/=\000,@$_=<>}; my $count=@$_;print $count, " li +nes\n";' </tmp/16 1 lines 0.47sec 0.28usr 0.18sys (99.77% cpu)
Shouldn't the first have read it into a temp array pointed to by $_, then got the count from @$_?time perl -e '{$/=undef, $_=<>} my $count=split /\000/,$_; print $coun +t, " lines\n";' </tmp/16 4118704 lines 0.47sec 0.28usr 0.18sys (99.77% cpu)
FWIW, also tried binmode STDIN at the front - same thing. What am I forgetting?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why doesn't this work?
by LanX (Saint) on Apr 12, 2013 at 21:42 UTC | |
by perl-diddler (Chaplain) on Apr 12, 2013 at 21:57 UTC | |
by LanX (Saint) on Apr 12, 2013 at 22:35 UTC | |
by choroba (Cardinal) on Apr 12, 2013 at 22:39 UTC | |
|
Re: Why doesn't this work?
by ww (Archbishop) on Apr 12, 2013 at 21:59 UTC | |
by perl-diddler (Chaplain) on Apr 12, 2013 at 22:08 UTC | |
by perl-diddler (Chaplain) on Apr 12, 2013 at 22:18 UTC | |
|
Re: Why doesn't this work?
by Corion (Patriarch) on Apr 12, 2013 at 21:35 UTC | |
by perl-diddler (Chaplain) on Apr 12, 2013 at 21:55 UTC | |
by Corion (Patriarch) on Apr 12, 2013 at 22:05 UTC | |
|
Re: Why doesn't this work?
by hdb (Monsignor) on Apr 12, 2013 at 21:33 UTC | |
by perl-diddler (Chaplain) on Apr 12, 2013 at 22:01 UTC | |
by hdb (Monsignor) on Apr 13, 2013 at 06:54 UTC |