On topic: The Wednesday Challenge

Simon Wistow simon at thegestalt.org
Wed Aug 15 16:10:45 BST 2007

On Wed, Aug 15, 2007 at 03:01:00PM +0100, Andy Armstrong said:
> $ perl myprog.pl < 64m.bin > 64m.sorted.bin

What's the format of 64.bin - just a sequence of bytes?


In which case it can only be a sequence of bytes representing 0..255.

Worst case scenario for this is 64Mb of FF

my @bytes;
while (read STDIN, my $scalar, 1) {
    $bytes[unpack("C", $scalar)]++;

for (0..$#bytes) {
    if (defined $bytes[$_]) {
        print pack("C",$_)x$bytes[$_];

It's possible that %bytes and sort keys %bytes might be better.

More information about the london.pm mailing list