Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Behaviour of unpack() with the Z template

by Anonymous Monk
on Feb 07, 2017 at 18:11 UTC ( [id://1181326]=note: print w/replies, xml ) Need Help??


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

Hi. Check against the suite https://perl5.git.perl.org/perl.git/blob/HEAD:/t/op/pack.t
  • Comment on Re: Behaviour of unpack() with the Z template

Replies are listed 'Best First'.
Re^2: Behaviour of unpack() with the Z template - 2nd attempt
by johngg (Canon) on Feb 08, 2017 at 10:12 UTC

    Thank you for the link. This line

    ['u', 'Z*', "foo\0bar \0", "foo"]

    defines the test for an unpack using the 'Z*' template and it would appear that a successful test would not leave a trailing null in the resultant string. I think this confirms that the expected behaviour is that the first null and everything to its right will be stripped. I think the use of "after" in Z strips everything after the first null is misleading and the wording should be clarified. Perhaps Z strips everything from the first null onwards would be a more accurate description.

    Cheers,

    JohnGG

Re^2: Behaviour of unpack() with the Z template
by johngg (Canon) on Feb 07, 2017 at 23:32 UTC

    Thank you for the link. This line

    ['u', 'Z*', "foo\0bar \0", "foo"]

    defines the test for an unpack using the 'Z*' template and it would appear that a successful test would not leave a trailing null in the resultant string. I think this confirms that the expected behaviour is that the first null and everything to its right will be stripped. I think the use of "after" in Z strips everything after the first null is misleading and the wording should be clarified. Perhaps Z strips everything from the first null onwards would be a more accurate description.

    Cheers,

    JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-20 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found