foreach my $key (@aminos){ #used to create an array with all values of the matrix foreach my $key2 (@aminos){ @matrix_numbers = $matrix->{$key}->{$key2}; } } print @matrix_numbers;