in reply to Re^2: I need a regExp to add spaces
in thread I need a regExp to add spaces
my $vlen = 1; $LimitValue = sprintf("%-${vlen}.${vlen}s", $LimitValue);
The "real" sprintf to do variable field sizes is:
$LimitValue = sprintf("%-*s", $vlen, $LimitValue);
You can also do:
if you wanted to reuse the formatter elsewhere.$formatter = sprintf( "%%-%d.%ds", $vlen, $vlen ); $LimitValue = sprintf($formatter, $LimitValue);
c.
|
|---|