or just:sub copy_hash { my $hr = shift // return {}; my $copy; @$copy{keys %$hr} = value %$hr; $copy; }
Or without a sub:sub copy_hash {{%{$_[0]//{}}}}
my %copy = %+;
In reply to Re^3: %+ and cloning
by JavaFan
in thread %+ and cloning
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |