Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
There's more than one way to do things
 
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"; }


Comment on Re^3: Entering the land of Perl
Select or Download Code

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 rifling through the Monastery: (5)
As of 2014-04-18 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (460 votes), past polls