in reply to Re: push onto hash!
in thread push onto hash!
As noted later, your use of ref is not necessary because you can autovivify the hash entry and push onto it in one step:
push @{$somehash{"$foo$bar"}}, $x;However, another point is to reconsider ever using ref. As was made clear to me this node, most uses of ref indicate that the code design should be revisited. ref is typically used to handle "special cases" and make things magically "work", which typically suggests a design flaw. Go to that link and read it. Good stuff! Once I grokked it, I rewrote the main loop in the code that I was making my point with and discovered that my new loop, without using ref, was smaller and easier to maintain.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
|---|