Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Entering the land of Perl

by jwkrahn (Abbot)
on Apr 05, 2013 at 14:37 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1027142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-19 06:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found