in reply to Padding with \s
Well you can use sprintf, but I don't see why there's any need for a while loop.
$str = sprintf '%-40s', $str; [download]
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg