Yes, I'm not a frequent user of
pack and
unpack so I often forget what tricks they can do. So, here's the full solution, more than five times faster than my previous one:
my @masks = qw( 11011010101101010101010101101010
10110110011011001100110011011001
01110001111000111100001111000111
00001111111000000011111111000000
00000000000111111111111111000000
00000000000000000000000000111111
11111111111111111111111111111111 );
sub ecc {
my ($hex) = @_;
my $d = unpack 'B32', pack 'H8', $hex;
my @r;
push @r, unpack '%1B*', $_ & $d for @masks;
$r[-1] = unpack '%1B*', $r[-1] . join "", @r[ 0 .. $#r - 1 ];
return join "", @r
}
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.