in reply to Re: Hash table question
in thread Hash table question

This is indeed proper*, and is quite efficient. Without needlessly and prematurely optimizing, for the first case, one might consider checking (scalar keys %hash1) <=> (scalar keys %hash2) and perform the constraining loop on the smaller hash. This would only have a significant benefit if the discrepancy in hash sizes is significant.

* (Except the wreck if it finds the false keys of '' and '0', as merlyn mentioned.)

Update: Separately, I agree that grep also works as a perl-idiom alternative to foreach, but that shouldn't change the actual effectiveness to my knowledge.

--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
•Re: Re: Re: Hash table question
by merlyn (Sage) on Jun 24, 2003 at 17:01 UTC