in reply to Re^2: How to build a hash?
in thread How to build a hash?
I had myself problems with it recently. As long as you storing scalars, it work perfectly as coded in the examples above. When it comes to references, your fears become true.
You sound a little confused. You can only ever store scalars in a hash. A reference is just a special kind of scalar. You can never overwrite an entire hash by assigning to one of its values.
my %my_hash; sub my_store($\%){ my($key,$ref) = @_; $my_hash{$key} = {%$ref} }
I'd guess it's almost certainly the unnecessary use of prototypes that is confusing you there :)
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to build a hash?
by Ben Win Lue (Friar) on Apr 25, 2005 at 13:20 UTC | |
by davorg (Chancellor) on Apr 26, 2005 at 15:16 UTC |