Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

pack() v unpack() padding: bug or ???

by BrowserUk (Patriarch)
on Feb 16, 2015 at 13:44 UTC ( #1116868=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        a  A string with arbitrary binary data, will be null padded.
        A  A text (ASCII) string, will be space padded.
        Z  A null-terminated (ASCIZ) string, will be null padded.
    
  2. or download this
    print length pack '(A2)*', 'fr','ed','x';;
    6
    ...
    
    print unpack 'C*', pack '(Z2)*', 'fr','ed','x';;
    102 0 101 0 120 0  ## Note! the 'r' & 'd' characters have been thrown 
    +away? Another bug?
    
  3. or download this
    printf "'%s'\n", join"'", unpack '(A2)*', 'fredx';;
    'fr'ed'x'
    ...
    
    printf "'%s'\n", join"'", unpack '(Z2)*', 'fredx';;
    'fr'ed'x'
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1116868]
Approved by marto
Front-paged by Discipulus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2022-05-25 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?