in reply to Re: I need a regExp to add spacesin thread I need a regExp to add spaces
my $vlen = 1; $LimitValue = sprintf("%-${vlen}.${vlen}s", $LimitValue); [download]
The "real" sprintf to do variable field sizes is:
$LimitValue = sprintf("%-*s", $vlen, $LimitValue); [download]
You can also do:
$formatter = sprintf( "%%-%d.%ds", $vlen, $vlen ); $LimitValue = sprintf($formatter, $LimitValue); [download]
c.