in reply to printf() formats
Update: I guess I shouldn't have assumed it wouldn't work before providing an alternative. The direct translation should work fine:
my $w = 5; my $p = 3; my $s = "abcdefg"; printf "<%*.*s>", $w,$p,$s;
My original answer below is an alternative though.
Something like the following will work for you:
Edit: added that ", $s" to the printf in the bottom example and added a quote in my first example. Thanks fglock++ and ichimunki++!my $w = 5; my $p = 3; my $s = "abcdefg"; printf "<%$w.${p}s>\n", $s;
-sauoq "My two cents aren't worth a dime.";
|
|---|