Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (16)
As of 2015-10-13 14:05 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (307 votes), past polls