in reply to I've muddled my bit and byte formats.
Just from reading your description, my (WA)guess is you're looking for something like this:
#!/usr/bin/perl # https://perlmonks.org/?node_id=1223702 use strict; use warnings; my @binimage = ( "\x00", "\x00", "\x00", "\x00", "\x00", "\x90" ); my $matrix = join "\n", map({ unpack 'B*', $_ } reverse @binimage), '' +; my $transform = ''; # transpose matrix $transform .= "\n" while $matrix =~ s/^./ $transform .= $&; '' /gem; print "$transform\n"; # debug print to validate transpose my $output = pack 'B*', $transform =~ tr/\n//dr; # remove \n, convert +to bits printf "output = %v08B\n", $output;
Outputs
100000 000000 000000 100000 000000 000000 000000 000000 output = 10000000.00000000.00100000.00000000.00000000.00000000
|
|---|