Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: %+ and cloning

by JavaFan (Canon)
on Jan 11, 2010 at 12:40 UTC ( #816711=note: print w/ replies, xml ) Need Help??


in reply to Re^2: %+ and cloning
in thread %+ and cloning

That depends on ones definition of 'best'. One could also write:

sub copy_hash { my $hr = shift // return {}; my $copy; @$copy{keys %$hr} = value %$hr; $copy; }
or just:
sub copy_hash {{%{$_[0]//{}}}}
Or without a sub:
my %copy = %+;


Comment on Re^3: %+ and cloning
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-07-06 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls