Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: how to unpack a C struct with length array preceding data array

by ig (Vicar)
on May 22, 2013 at 23:32 UTC ( [id://1034829]=note: print w/replies, xml ) Need Help??


in reply to how to unpack a C struct with length array preceding data array

If you really want to do it in one unpack you can...

use strict; use warnings; use Data::Dumper; my @arr = unpack('(W W @0Wx/a @1W@0Wx/x/a)', "\005\006Hello World"); print Dumper(\@arr);

Which produces:

$VAR1 = [ 5, 6, 'Hello', ' World' ];

But I would never do that, except to prove that I could.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2024-04-19 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found