#! perl -slw use strict; sub doit { my $in = shift; my $buf; my @out = (); while( length( $in ) ) { $buf = ''; $buf = $buf . chop $in for (0..2); for( 0 .. 3 ) { push @out, ($buf & 64); $buf >>= 6; } } return @out } our $packed = pack 'C*', qw[ 00 16 131 16 81 135 32 146 139 48 211 143 65 20 147 81 85 151 97 1 +50 155 113 215 159 ]; print join ' ', map sprintf( "%02d", $_ ), doit( $packed ); __END__ C:\test>junk10 Argument "ƒÎq" isn't numeric in bitwise and (&) at C:\test\junk10.pl l +ine 12. Argument "øûa" isn't numeric in bitwise and (&) at C:\test\junk10.pl l +ine 12. Argument "ùUQ" isn't numeric in bitwise and (&) at C:\test\junk10.pl l +ine 12. Argument "ô^TA" isn't numeric in bitwise and (&) at C:\test\junk10.pl +line 12. Argument "M-^OË0" isn't numeric in bitwise and (&) at C:\test\junk10.p +l line 12. Argument "ïÆ " isn't numeric in bitwise and (&) at C:\test\junk10.pl l +ine 12. Argument "çQ^P" isn't numeric in bitwise and (&) at C:\test\junk10.pl +line 12. Argument "â^P\0" isn't numeric in bitwise and (&) at C:\test\junk10.pl + line 12. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0 +0 00 00 00 00 00 00 00 00

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^2: unpacking 6-bit values by BrowserUk
in thread unpacking 6-bit values by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.