Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

How does backing up several bytes work with unpack? (a bug?) (was: Re^2: Can unpack add zero bytes before converting?)

by vr (Curate)
on Sep 13, 2021 at 20:40 UTC ( #11136722=note: print w/replies, xml ) Need Help??


in reply to Re: Can unpack add zero bytes before converting?
in thread Can unpack add zero bytes before converting?

I had to explicitly include a count in template: "(QX$pad_len)$count", instead of simply "(QX$pad_len)*", because otherwise @values array would result in a very puzzling length of 2501 items instead of 1000 i.e. $count.

I suspect there's special code somewhere to prevent ((un?)documented(?) case of) endless loops with '(CX)*' or '(vX2)*' or similar, but still:

say for unpack '(VX2)*', "\1\1\1\1"; # why 2 items? say for unpack '(VX3)*', "\1\1\1\1"; 'X' outside of string in unpack # how's that?

and why 2501 items with '(QX3)*' template to begin with?

  • Comment on How does backing up several bytes work with unpack? (a bug?) (was: Re^2: Can unpack add zero bytes before converting?)
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2023-09-23 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?