Tiny, active code segment
...
$sr_len = sysread(IN, $buf, $bsize); # SysRead Length
last if $sr_len == 0;
while($buf) {
$rgb=substr($buf, 0, 6, ''); # Nibble 6 bytes
$rgb2c{$rgb}++;
}
####
@rgb = keys %rgb2c; << 1 line takes 28.648 min
##
##
my $fsize = -s [your file]; ## Find out how big the image is?
my $arrsize = $fsize / 6; ## Size of the array and hash
my $counter = 0;
my %rgb2c;
keys %rgb2c = $arrsize; ## Allocate one large memory hash!
my @rgb[$arrsize] = ''; ## Allocate one large memory array!
while ( 1 )
{ $sr_len = sysread(IN, $buf, $bsize); # SysRead Length
last if $sr_len == 0;
while($buf)
{ $rgb=substr($buf, 0, 6, ''); # Nibble 6 bytes
$rgb2c{$rgb}++;
$rgb[$counter} = $rgb; # Build array as you go along
$counter++;
}
}