Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Behaviour of unpack() with the Z template

by johngg (Canon)
on Feb 08, 2017 at 10:25 UTC ( [id://1181397]=note: print w/replies, xml ) Need Help??


in reply to Re: Behaviour of unpack() with the Z template
in thread Behaviour of unpack() with the Z template

the Z5 pattern makes perl read the first five bytes and strip away everything after the first null byte

I agree with your analysis but the word "after" here and in the documentation is where I see a problem. It implies that only text that follows the null will be stripped, not the null itself. The behaviour makes sense, the description is, I think, wrong.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: Behaviour of unpack() with the Z template
by Eily (Monsignor) on Feb 08, 2017 at 15:10 UTC

    That was precisely my point, that the null byte is not ignored like the other characters after it. It's part of the data when encoded in the format "null-terminated string", but not part of the value. It doesn't appear in the output value because it's a format detail, the same way the byte order doesn't appear after decoding a little endian or big endian integer value.

    But that's nitpicking, this would make the documentation misleading rather than plain wrong, which should also be avoided in a documentation. I think your phrasing returns everything up to but not including the first null. is fine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-29 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found