Perhaps later, I'll put up a version that does all of the work in binary strings rather than arrays.open(FILE, shift) or die $!; my (@buffer, @bits); while(!eof(FILE)) { if (@buffer == 0) { #if it's empty, fill it my $bytes; #read 30 bytes at a time read(FILE, $bytes, 30); my @ary = map {ord} split("", $bytes); foreach my $byte (@ary) { push @buffer, split("", unpack("B*", $byte)); } } while(@bits < 128) { push (@bits, shift(@buffer)); last if (@buffer == 0); } #the first couple of reads will not fill the bits array next if (@bits < 128); #your processing on @bits goes here shift @bits; }
thor
In reply to Re: perl bitology - breaking into bytes
by thor
in thread perl bitology - breaking into bytes
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |