Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by GotToBTru (Prior)
on Feb 16, 2015 at 16:02 UTC ( [id://1116885]=note: print w/replies, xml ) Need Help??


in reply to pack() v unpack() padding: bug or ???

printf "'%s'\n",join "'",unpack '(A2)*','fredx ' 'fr'ed'x'

unpack is deciding to remove trailing spaces, I guess in the assumption that they are artifacts from pack.

Dum Spiro Spero

Replies are listed 'Best First'.
Re^2: pack() v unpack() padding: bug or ???
by BrowserUk (Patriarch) on Feb 16, 2015 at 16:52 UTC
    unpack is deciding to remove trailing spaces, I guess in the assumption that they are artifacts from pack.

    Same question: can anyone describe the use they made of that? Or even think of a use for it?

    In the end it all comes down to my need to chop an arbitrary length string into n-byte chunks; and the requirement to have the last chunk padded if it is shorter than n.

    It seems to me that this is a fairly common requirement -- think all the Digest::* modules that need to operate upon fixed-sized chunks of data -- and there isn't (AFAIK) a clean way to do that.

    And here we have a couple of templates that almost do it; but at the margins, do something that whilst they can be reasoned (with squinty eye's and big dollop of belief suspension), to be "doing the opposite of pack"; do things that there are no good uses for; whilst leaving the common requirement unserviced.

    That's just not very Perlish.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-03-28 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found