Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re^6: Set Operatorsby Notromda (Pilgrim) |
on Oct 28, 2002 at 21:18 UTC ( [id://208610]=note: print w/replies, xml ) | Need Help?? |
This doesn't mean grep is the be-all end-all solution: if you need to check many values against the same set, then constructing the hash will quickly pay off as all subsequent lookups run in nearly constant time. Esp when the set is large and even more so when the values are typically absent more often than not, the overhead of building the hash will pay off rapidly. Indeed, this was the case I had in mind. I guess it comes down to which is more readable, my %items = map {$_ => 1} qw (one two three); or:
I'm still not clear on why that last one works...
In Section
Seekers of Perl Wisdom
|
|