Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Generating standard length strings

by crashtest (Curate)
on Apr 14, 2005 at 19:04 UTC ( [id://447916]=note: print w/replies, xml ) Need Help??


in reply to Generating standard length strings

And just for variety (TIMTOWTDI, after all), I first thought of using pack:
sub pad{ my ($string, $length) = @_; return (length($string) < $length ? pack("A$length", $string) : $st +ring); }
... although after reading all the responses, I agree that sprintf is the best way to go.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-19 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found