Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: PERL Binary Data Handling

by Anonymous Monk
on Oct 05, 2012 at 20:55 UTC ( #997547=note: print w/ replies, xml ) Need Help??


in reply to PERL Binary Data Handling

Sample input? Expected output?

I usually try to figure this out with real data, something where you know what result you're expecting, along the lines of

$ perl -le " print join q/ /, unpack q/(A4)*/, unpack q/B*/, pack q/B +33/, 1, 66 " 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 $ perl -le " print join q/ /, unpack q/(A2)*/, unpack q/H*/, pack q/B3 +3/, 1,66 " 80 00 00 00 00

or maybe

$ perl -le " print join q/ /, unpack q/(A2)*/, unpack q/H*/, pack q/B3 +3/, join q//, 1, unpack q/B32/, 66 " 9b 1b 00 00 00 $ perl -le " print join q/ /, unpack q/(A4)*/, unpack q/B*/, pack q/B3 +3/, join q//, unpack(q/B1/,1), unpack q/B32/, 66 " 1001 1011 0001 1011 0000 0000 0000 0000 0000 0000

or even

$ perl -le " print join q/ /, unpack q/(A4)*/, unpack q/B*/, pack q/B3 +3/, join q//, unpack(q/B1/,1), unpack q/B32/, 66 " 0001 1011 0001 1011 0000 0000 0000 0000 0000 0000


Comment on Re: PERL Binary Data Handling
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (14)
As of 2015-07-06 19:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (81 votes), past polls