in reply to Unpacking binary data with unpack()?
#! perl -w use strict; sub same { shift; } sub unpacka { unpack "A*", shift; } sub unpackh { unpack "H*", shift; } sub unpackc { unpack "C*", shift; } sub test { my $code = shift; my $input = "HAL 2001"; my $wanted = "48414C2032303031"; my $testout = $code->($input); if ($testout =~ /^$wanted$/i) { print "pass\n"; } else { print "fail |$wanted|$testout|\n"; } } test \&same; test \&unpacka; test \&unpackh; test \&unpackc; __END__ fail |48414C2032303031|HAL 2001| fail |48414C2032303031|HAL 2001| pass fail |48414C2032303031|72|
|
|---|