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

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

by BrowserUk (Patriarch)
on Feb 16, 2015 at 16:52 UTC ( #1116898=note: print w/replies, xml ) Need Help??

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

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
  • Comment on Re^2: pack() v unpack() padding: bug or ???

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2022-05-22 12:11 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (80 votes). Check out past polls.