Your skill will accomplish what the force of many cannot |
|
PerlMonks |
pack/unpack woesby james289o9 (Acolyte) |
on Jun 14, 2022 at 20:50 UTC ( [id://11144736]=perlquestion: print w/replies, xml ) | Need Help?? |
james289o9 has asked for the wisdom of the Perl Monks concerning the following question: Originally i tried to ask in the chatterbox, but i think that i may have mis-translated what i am trying to do. So without further ado: I have an ogg/opus audio file that i am trying to read the header, which is 28 bytes or 0x1C in length. Here is the code i am using to read this header: and here is the 28 byte header:
The more i think about this the more i wonder if unpack C is not what i want to do anyway. are the single bytes already in unpack C format? if so, how can i just store that value into the variable without any conversion so any further printing or processing the actual raw values eg print $ogg_magic will print "OggS" Or maybe i am just completely confused by pack and unpack. i can use read() and i can easily print those values or translate them into expected formats, but i think unpack C is messing me up somehow? or ... OR... maybe i am just completely confused. If i need to elaborate any more please just let me know. P.S. i guess what i am wondering in the end is, how can i make pack or unpack assign the same values as read($file, my $buf, n);? i can work with whatever data read stores (im assuming binary?) but i cannot get the same values/data to store in those variables with unpack or pack. hope i am clear, if not just give me a swift kick in the hind quarters and tell me what other info you need. and as always any help is certainly appreciated :)
Back to
Seekers of Perl Wisdom
|
|