in reply to conditional string formatting

Actually, I think I like this one better than either choroba's or mine above:

c:\@Work\Perl\monks>perl -wMstrict -le "my @names = qw(A AB ABC ABCD ABCDE); ;; for my $name (@names) { printf qq{%8s -> }, qq{'$name'}; my $s = sprintf length($name) > 3 ? '%s' : ' %-3s', $name ; print qq{'$s'}; } " 'A' -> ' A ' 'AB' -> ' AB ' 'ABC' -> ' ABC' 'ABCD' -> 'ABCD' 'ABCDE' -> 'ABCDE'
Make the first  '%s' into  '%4.4s' to limit the field to the first four characters only.


Give a man a fish:  <%-(-(-(-<