Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Function to produce formatted ord values of a string

by GrandFather (Saint)
on Apr 20, 2012 at 12:52 UTC ( [id://966189]=note: print w/replies, xml ) Need Help??


in reply to Function to produce formatted ord values of a string

Being as this is Perl we are using I'd ponder using a regular expression:

sub new_regex { my $buf = shift; $buf =~ s/(.)/sprintf '%3d ', ord($1)/ge; chop $buf; return $buf; }

The chop is needed for the test to remove a trailing space and may not be needed in a "real" application.

True laziness is hard work

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-26 08:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found