in reply to Port Java code to Perl help
Perhaps:
sub dashedHexToBytes{ join'', map pack( 'H*', $_ ),split'-', $_[0] };;
print dashedHexToBytes( '3f-ff0c-1234-af12' );; ? ♀↕4»↕
Or
sub dashedHexToBytes{ local $_ = shift; tr[-][]; return pack( 'h*', $_ ); };;
print dashedHexToBytes( '0123-4567-89ab-cdef-0123-4567-89ab-cdef' );; ►2MeÎÿ║═Ý▀►2MeÎÿ║═Ý☼
Note: In both examples, you may need to switch from 'H*' to 'h*' or vice versa depending on the endianess of the originating system and that of the receiving system.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Port Java code to Perl help
by jaakko_m (Initiate) on Apr 23, 2012 at 03:55 UTC |