views:

199

answers:

1

I want to push a reference to a hash. By that I mean I want to push a reference to a new hash that is a shallow copy of the hash I am given.

How do I create the shallow copy?

+9  A: 

Just copy it:

 my %copy = %$hash;

If you want another reference, just expand the original reference in the anonymous hash constructor:

 my $copy = { %$hash };
brian d foy