use strict;
use warnings;

my @newarray;
my ($xnumvar,$xvar,$ynumvar,$yvar,@maxlength);
my @newmatrix=(["123.45","JOHN DOE","Coal Miner"],
           ["12.45","MR. PEANUT","peanut"],
           ["4.1","Bill Clinton","unknown"]);
# iterate through each element and gather maximum character length for each
column
# The overall purpose of this is to take a given matrix and line
# up the print output based on the maximum character length of each column +
2
[EMAIL PROTECTED];
for ($xvar=0; $xvar < $xnumvar; $xvar++) {
 [EMAIL PROTECTED];
 for ($yvar=0; $yvar < $ynumvar; $yvar++) {
  if (length($newmatrix[$yvar]) > $maxlength[$yvar] ) {
   $maxlength[$yvar]=length($newmatrix[$yvar])
  }
 }
}
my $curline=0;
my $cols;
foreach my $arrayline (@newmatrix) {
  my [EMAIL PROTECTED];
   for (my $cols=0; $cols < $coltotal ; $cols++) {
    # this line hung the compiler up on win, I'm not understanding how I can
build a dynamic parameter
    # string and pass as a parameter within the function call.
    #$newmatrix[$curline][$cols]=sprintf("%-" . $maxlength[$cols]+2 .
"s%",$newmatrix[$curline][$cols]);
    $curline=$curline+1;
   }
}
# need to simply print the matrix here, but dont know how to efficiently
print a entire matrix
print @newmatrix;

TIA to those who have some spare time to explain.
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to