Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Function to produce formatted ord values of a string

by BrowserUk (Patriarch)
on Apr 20, 2012 at 09:43 UTC ( [id://966153]=note: print w/replies, xml ) Need Help??


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]; } }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://966153]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2024-03-28 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found