package utils1; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( invert_aoa print_hash print_aoa highest_number ); sub invert_aoa{ use strict; use warnings; use 5.010; my $a = shift; my @AoA = @$a; my $k = $#AoA; #say "k is $k"; my @BoB; for my $i ( 0 .. $#AoA ) { my $aref = $AoA[$i]; my $x = $#{$aref}; #say "x is $x"; for my $j ( 0 .. $#{$aref} ) { $BoB[$j][$i]= $AoA[$i][$j]; } } my $b = \@BoB; return $b; } sub print_aoa{ use warnings; use 5.011; my $a = shift; my @AoA = @$a; for my $i ( 0 .. $#AoA ) { my $aref = $AoA[$i]; for my $j ( 0 .. $#{$aref} ) { print "elt $i $j is $AoA[$i][$j]\n"; } } return $a; } sub highest_number{ use strict; use File::Basename; use Cwd; my ($aref, $filetype, $word) = @_; my $number; my @matching; my $ext = ".".$filetype; push (@matching, 0); #min returned value for my $file (@{$aref}) { #print "file is $file\n"; if ($file =~ /^$word(\d+)$ext$/){ #print "matching is $file\n"; push (@matching, $1); } } @matching = sort @matching; my $winner = pop @matching; return $winner } sub print_hash{ use 5.011; my $hash_ref = shift; ## 10-15-18 adding sorted keys print "subroutine says this is your hash: \n"; my %hash = %$hash_ref; foreach my $name (sort keys %hash) { say "key: $name, value: $hash{$name}\n"; } } 1;