I'd consider Bit::Vector to ensure a (supposed :) best combination of speed and platform-independence, not to mention ease of use:
use Bit::Vector; my $size=16; my $bits = Bit::Vector->new_Bin($size,"1101000010101111"); print "orig:\t\t",$bits->to_Bin(), "\n"; $bits->Interval_Reverse(($_-1)*8,$_*8-1) for (1..($size/8)); print "byte-rev:\t",$bits->to_Bin(), "\n"; __END__ orig: 1101000010101111 byte-rev: 0000101111110101
regards,
tomte
Hlade's Law:
If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.
In reply to Re: Reversing chunks in a string (bits of byte in a bitstring)
by Tomte
in thread Reversing chunks in a string (bits of byte in a bitstring)
by spurperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |