Win8 Strawberry 5.30.3.1 (64) Tue 06/14/2022 17:01:38 C:\@Work\Perl\monks >perl use strict; use warnings; use Data::Dump qw/dd pp/; my $ogg_head = pack 'H*', '4F6767530002000000000000000083CA3DC0000000009F59730A0113'; dd $ogg_head; # for debug my ($ogg_magic, $opus_version, $flags, $granule_position, $serial_number, $sequence_number, $checksum, $total_segments, $segment_size) = # unpack('C4 C1 C1 C8 C4 C4 C4 C1 C1', $buf); unpack('a4 C C Q N N N C C', $ogg_head); print "'$ogg_magic' \n"; dd $ogg_magic, $opus_version, $flags, $granule_position, $serial_number, $sequence_number, $checksum, $total_segments, $segment_size; printf "%s %02x %02x %08x %04x %04x %04x %02x %02x \n", $ogg_magic, $opus_version, $flags, $granule_position, $serial_number, $sequence_number, $checksum, $total_segments, $segment_size; ^Z pack("H*","4f6767530002000000000000000083ca3dc0000000009f59730a0113") 'OggS' ("OggS", 0, 2, 0, 2211069376, 0, 2673439498, 1, 19) OggS 00 02 00000000 83ca3dc0 0000 9f59730a 01 13
Note: Check that your version of Perl supports the Q pack/unpack template specifier.


Give a man a fish:  <%-{-{-{-<


In reply to Re: pack/unpack woes by AnomalousMonk
in thread pack/unpack woes by james289o9

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.