Notice that I have to dereference it after the passage. So the hope is that there is no copying.
In your code you have:
sub sort_and_print_hash_keys (\%) { my %hash = %{shift()}; foreach (sort keys %hash) { print "$hash{$_} "; } print "\n"; }
Which is copying the entire hash. If you didn't want to copy the hash you could do it like this:
sub sort_and_print_hash_keys (\%) { my $hash = shift; foreach (sort keys %$hash) { print "$hash->{$_} "; } print "\n"; }
In reply to Re^3: Entering the land of Perl
by jwkrahn
in thread Entering the land of Perl
by manbroski
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |