I think the problem is just in
@in and not the
pack/
unpack .. When you pack @in in H2's, it's ('0','1','0','2','0','3') ... I hardcoded it as ('01', '02', '03') in a test run and it gave your desired output..
Probably not the best way, but this works:
my @in = grep length $_, split(/(..)/, $string);
shift @in; # just 1 shift to pull off '0x'
my $bytes = scalar(@in); # no longer need the div by 2