in reply to Why doesn't this work?

This works for me:

time perl -e '$_=[];@$_=<>; my $count=@$_;print $count, " lines\n";' < + somefile.txt time perl -e '{$/=undef, $_=<>} my $count=split /\n/,$_; print $count, + " lines\n";' < somefile.txt

Your second version does not when splitting on \000.

Replies are listed 'Best First'.
Re^2: Why doesn't this work?
by perl-diddler (Chaplain) on Apr 12, 2013 at 22:01 UTC
    The examples you list don't split on \000.

    They are not the examples from my code. (i.e. 2nd example was..)

    time perl -e '{$/=undef, $_=<>} my $count=split /\000/,$_; print $coun +t, " lines\n";' </tmp/16
    Wasn't it? Or am I REALLY confused?

      I cound not find even a single test file that would be more than one line under splitting on \000 so I was resorting to replacing the delimiter. So what I stated was correct but possibly irrelevant... ;)