When I try to pack more than 5 bytes using “H2” template, I can unpack the first 5 correctly but the rest are corrupted. Consider the script below:
my $a = "11:22:33:44:55:66";
my @b = split /:/, $a;
my @c = map {hex($_)} @b;
my $d = pack( 'H2'x6, @c );
my @e = unpack( 'H2'x6, $d);
foreach (@e) {
printf("%02x:", $_);
}
Outputs:
11:22:33:44:55:0a:
The last byte is output as “0a” and not “66” as I would have expected.