How can I convert a 48 hex string to bytes using Perl?

ron picture ron · Mar 11, 2010 · Viewed 19.7k times · Source

I have a hex string (length 48 chars) that I want to convert to raw bytes with the pack function in order to put it in a Win32 vector of bytes.

How I can do this with Perl?

Answer

Eugene Yarmash picture Eugene Yarmash · Mar 11, 2010
my $bytes = pack "H*", $hex;

See perlpacktut for more information.