Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: unpack into arrayrefs?

by Tux (Canon)
on Feb 22, 2022 at 16:54 UTC ( [id://11141554]=note: print w/replies, xml ) Need Help??


in reply to unpack into arrayrefs?

If the data shown in your OT is what you expect, make sure you get what you expect (S< or v instead of S), as that would otherwise fail on big-endian machines.

my $data = pack "H*" => "0000230ebb0000002b0ece000000330ee200"; my $f += [ map [ unpack "(CCS<S<)" ] => unpack "(A6)*" => $data ];'

or

my $data = pack "H*" => "0000230ebb0000002b0ece000000330ee200"; my $f += [ map [ unpack "(CCvv)" ] => unpack "(A6)*" => $data ];'

See this overview for what it means.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: unpack into arrayrefs?
by ikegami (Patriarch) on Feb 22, 2022 at 17:15 UTC

    That should be a, not A. A will remove trailing 0x20 bytes.


    S might be correct even on big-endian machines.

    • Use S for native endianness.
    • Use S< or v for little-endian.
    • Use S> or n for big-endian.

    If the OP was using a little-endian machine, we can only rule out the last one from the info provided.

    See Mini-Tutorial: Formats for Packing and Unpacking Numbers for a convenient table of pack/unpack numeric formats.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11141554]
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: (5)
As of 2024-03-29 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found