Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Padding with \s

by abitkin (Monk)
on Sep 13, 2002 at 16:27 UTC ( #197646=note: print w/replies, xml ) Need Help??


in reply to Padding with \s

How about this?

$var .= substr(" " x 40, length($var)) if length($var) < 40;

The if is so that you don't get warnings about undefined vars.

If you want to print:
print $var . (length($var)<40?substr(" " x 40, length($var)):"");

Though I'm sure someone can optimize it a little better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2020-06-05 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (40 votes). Check out past polls.

    Notices?