Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Padding with \s

by abitkin (Monk)
on Sep 13, 2002 at 16:27 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://197646]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-25 19:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found