in reply to sysread and null characters

Because I just couldn't resist:  perl -le'$/=\1024; while(<>){ $x[$_]++ for split//}' /path/to/pi Note that I set $/ to a reference to 1024, which causes the <> operator to read chunks of 1024 characters at a time. Also note that I used an array to store the values in stead of a hash, with a total of 9 digits, an array should be faster and more space efficient.

Update: as frodo72 pointed out, it was indeed missing a closing curly bracket. Fixed.

Replies are listed 'Best First'.
Re^2: sysread and null characters
by halley (Prior) on Mar 24, 2005 at 15:05 UTC
    Some corrections and new ideas; you want to be able to output your results, right?
    perl -F// -lane 'BEGIN{$/=\1024} $x[$_]++for@F; END{print $x[$_]for 0..9}' /path/to/pi
    Too bad the -O command switch can't take \1024. That's a cool trick.

    --
    [ e d @ h a l l e y . c c ]