Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Entering the land of Perl

by jwkrahn (Monsignor)
on Apr 05, 2013 at 14:37 UTC ( #1027142=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2016-06-27 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (335 votes). Check out past polls.