Joseph wrote:
>
> "John W. Krahn" wrote:
>
> > Jason Dusek wrote:
> > >
> > > Hi Perl Beginners,
> >
> > Hello,
> >
> > > Let's say I have a hash of hashes.  And I want to use it over and over
> > > again, so I need to reinitialize it often.  I suppose I could go
> > > through each key in the hash of hashes, and go through each key in the
> > > little hashes and use delete on each of them.  But isn't there some
> > > elegant way?  Does Perl have a nuke() operator?
> >
> > If you want to clear out the hash completely then:
> >
> > %hash = ();
> >
> > Will remove all the keys and values from the hash.  This will also work
> > with a hash of hashes.
> >
> > Or if you need to reinitialize it you can just assign the key/value
> > pairs to the hash:
> >
> > %hash = ( newkey1 => 'newval1', newkey2 => 'newval2' );
> >
> > Which will assign the new list, replacing anything that was in there
> > before.
> >
> > John
>
> Thanks, John,
>
> That indeed is one of the conveniences that makes one truly appreciate the
> beauty of Perl reference-counting, anonymous data structures, and the use of
> references.  Makes cleanups fast and easy.

Hi Joseph.

I agree with your point, but there's no reference counting involved here
(unless the hash values were themselves references).

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to