Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 ( #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.


Comment on Re: how to unpack a C struct with length array preceding data array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2015-07-02 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (45 votes), past polls