in reply to String to hex
This seems pretty legible
sub str_to_hex { my $str = shift; return "0x" . substr(unpack("H*", $str), 0, 4); } print str_to_hex("COM7") . "\n"; # outputs: 0x434f
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: String to hex
by Anonymous Monk on Aug 09, 2012 at 13:58 UTC | |
by influx (Beadle) on Aug 09, 2012 at 14:46 UTC |
In Section
Seekers of Perl Wisdom