in reply to Function to produce formatted ord values of a string
Personally, if the application permitted it, I'd go for:
sub ords{ sprintf "%02x " x length($_[0]), unpack 'C*', $_[0]; }
In addition to being a bit quick, I find the shorter dumps using hex more useful.
If I was really after ultimate speed and the strings to be dumped were of some reasonable maximum length, then I might consider using:
{ my $t = '%02x ' x 1000; sub ords2{ sprintf substr( $t, 0, length $_[0]*5 ), unpack 'C*', $_[0]; } }
|
|---|