sub printMatrix1 { my ($A,$forprint,$header1) = @_; #$A is the matrix to be printed, $forprint is the format and $header1 is the header of the matrix to be printed open(OUT,">$header1.txt") or die "The File $header1.txt couldnīt be opened\n"; print OUT "$header1\n\n"; print OUT ' '; #prints space first so that upper letters stay formated in place my $format2= $forprint; substr ($format2,length($format2)-1,1,'s'); #### for printing upper letters in the matrix foreach my $key (@aminos){ #Prints Upper aminoacido letters of the Matrix printf OUT ("$format2 ", $key); } print OUT "\n"; foreach my $key (@aminos) { print OUT $key,' '; foreach my $key2 (@aminos ) { printf OUT ("$forprint " , $A->{$key}->{$key2}); } print OUT "\n"; } close OUT; }