I am not very familiar with the pack function, but it seems to me that your template expects only one value.
Maybe you should try
my $data = pack ('C*', @hexData);
And while you're on it, upgrade your code to something more:
my @arr = qw(50 00 9F 11 00 28 82 48 21 84 BC 00 01 02 01 00 09 01 38 00 23 05 08 01 01 02 00 00 18 00 50 05 00 00 00 00 00 00 00 00 02 00 0C FE CE 00 0F 00 FD FF 2D 00 00 00 00 00 04 01 0C FE); my @hexData; foreach my $elem (@arr) { push @hexData, hex($elem); } my $data = pack ('C*', @hexData); print $data;
Or even:
my $data = pack("C*", map(hex, @arr));
source share