in reply to •Re: Can you change the format pad character?
in thread Can you change the format pad character?
At least when the padding is whitespace (which the OP seemed to want), is this solution better than using (s)printf? For ex:
my $string = 'foo'; my $len = 15; $string = sprintf "%${len}s", $string; print $string;
Please note: Don't get me wrong. For fear of fire and brimstone, the Novice that I am would not presume to criticise merlyn. It's just that I've been playing with (s)printf recently, prompting me to change a few old progs from, like:
print ' ' x ( 23 - length $foo ), $foo;to:
printf '%23s', $foo;Have I been I wrong or (more likely), AIMS (Am I Missing Something)?
dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Re: •Re: Can you change the format pad character?
by merlyn (Sage) on May 27, 2003 at 20:23 UTC | |
by Not_a_Number (Prior) on Jun 01, 2003 at 17:44 UTC |