On 2013-03-04 17:22, Chris Stinemetz wrote:
I would like to pass a list of variables to printf.
Is there a way to multiply a set printf length instead of
righting typing printf for each variable?
what I am trying to do is below:
printf "%-${longest}s x 27\n",
$rptType,$mkt,$timeStamp,$cell,$sector,$carr,$satt,$sest,$fit,$psEst,$catt,$cest,$pcEst,$rfLost,
$cpDropCell,$cpDropRnc,$tuneAway,$tDrops,$pDcr,$ia,$pIa,$tccf,$failAp,$failTp,$failA10,$failAAA,$failPDSN;
There are many ways to do this. For 'lazy' values, use a subroutine.
Another approach:
perl -Mstrict -we'
my @data = qw/ abc d ef ghi jklmn /;
my $wid = 1;
$wid < length and $wid = length for @data;
print sprintf +("| %-${wid}s" x @data)." |\n", @data;
'
| abc | d | ef | ghi | jklmn |
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/