http://www.perlmonks.org?node_id=1027142


in reply to Re^2: Entering the land of Perl
in thread Entering the land of Perl

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"; }