in reply to Reading individual bits
For clarity I've omitted the $$OffsetRef part. Using proper bitmasks and the bitwise operators would probably be faster, see perlop.
sub ReadBits2 { my $bitstring = @_[0]; my $offset = @_[1]; my $length = @_[2]; return unpack "N", pack "B*", sprintf "%032s", substr $bitstring, $offset, $length; } sub ReadBits3 { return oct b . substr @_[0], @_[1], @_[2]; }
--
John.
|
|---|