[Memphis.pm] perl one liner

Steve Lane sml at zfx.com
Wed Sep 26 12:43:41 CDT 2001


Hal Phillips wrote:
> 
> Interesting, I ran this on and AIX s80 w 8gig of ram versus wc -l on a nigh
> million line file, and the perl won on time....  I wouldn't have guessed it!
> 
> box:/tmp> timex perl -lpe '}$_=$.;{' hal.tmp
> 989702
> 
> real 6.83
> user 5.42
> sys  1.41
> 
> box:/tmp> timex wc -l hal.tmp
>   989702 hal.tmp
> 
> real 11.45
> user 9.77
> sys  1.68

this is likely to be a hair faster:

timex perl -ne '}print$.-1 ."\n";{' hal.tmp

it's about 1% faster on my machine.

if you've got Deparse and want to see what's going
on with these examples, run these commands...

perl -MO=Deparse -lpe '}$_=$.;{' hal.tmp
perl -MO=Deparse -ne '}print$.-1 ."\n";{' hal.tmp

--
Steve Lane <sml at zfx.com>
----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------




More information about the Memphis-pm mailing list