Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Welcome to the Monastery
 
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 meditating upon the Monastery: (11)
As of 2014-04-19 15:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (482 votes), past polls