in reply to Trailing spaces to lines less than x characters
If the padding is only for printing (i.e., output), one can also do:
See sprintf for discussion of the * format specifier.c:\@Work\Perl\monks>perl -wMstrict -le "use constant MIN => 5; ;; my $s = ''; for my $c ('', 'a' .. 'h') { $s .= $c; printf qq{%12s -> '%-*s' \n}, qq{'$s'}, MIN, $s; } " '' -> ' ' 'a' -> 'a ' 'ab' -> 'ab ' 'abc' -> 'abc ' 'abcd' -> 'abcd ' 'abcde' -> 'abcde' 'abcdef' -> 'abcdef' 'abcdefg' -> 'abcdefg' 'abcdefgh' -> 'abcdefgh'
Give a man a fish: <%-(-(-(-<
|
|---|