my @array_of_hashes = \( %finalMap1, %finalMap2, ... ); foreach my $finalMap_ref ( @array_of_hashes ) { push @returned_sorted, [ sortedHash( %{$finalMap_ref} ) ]; push @percentile_index, [ percentile( @{$returned_sorted[-1]} ) ]; }
At that point, @{ $returned_sorted[ 2 ] } is what would have been @returned_sorted3 in your version. If you store your various %finalMap hashes in an array of hashes to begin with, you can avoid having them all listed out in the initial assignment. If you don't really need to keep the values of @returned_sorted, you can replace the loop's innards with this:
push @percentile_index, [ percentile( sortedHash( %{$finalMap_ref} ) ) ];
Since you're not doing this already, I'm guessing you're not familiar with references. If that's true, have a look at perlreftut and perlref. After that, maybe References quick reference.
In reply to Re: How to shorten this particular code
by kyle
in thread How to shorten this particular code
by max210
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |