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.