in reply to Padding with \s
How about this?
The if is so that you don't get warnings about undefined vars.
If you want to print:
Though I'm sure someone can optimize it a little better.
$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.
|
---|
In Section
Seekers of Perl Wisdom