Hey,
Thank you in advance.
So here is my code
Code:
my $mat ='Matrix.txt';
open MAT, "$mat" or die "Problem opening file, $!\n";
my $huge;
my @listrow;
while (my $line = <MAT>){
$huge .= $line;
chomp($line);
my @one_row=split(/\t/, $line);
#print "This is 1 row@one_row \n";
push @listrow, \@one_row;
}
my @dim=&DIM($huge); #so col in 0 row in 1
#print $listrow[0]->[3],"\n";
for (my $j=0;$j<=$dim[1];$j++){
for(my $i=0;$i<=$dim[0];$i++){
print "i ->$i\tj ->$j\n";
print " dim is -> @dim\n";
print $listrow[$j]->[$i],"\t";
}
print "\n";
}
sub DIM {
my $line = $_[0];
push my @row, (split /\n/, $line);
my @arr;
for (my $t=0; $t < @row; $t++){
push (@arr, split (/\t/, $row[$t]));
}
my @dim = @arr/@row;
$dim[1]=@row;
return @dim;# so col in 0 row in 1
}
So my two questions are this why does the for loop $listrow print out
"Use of uninitialized value in print at test.pl line 23."
and is there a better way to find the dimentions.
I know that I can print the matrix using the
way but I don't want to double up on my for loops.
Cheers
Paul