my @list1 = get_from_some_place(); my @list2 = get_from_some_other_place(); -------- # Hash method my %lookup_hash; @lookup_hash{@list2} = undef; # This is a hashslice. We don't care abo +ut the values. unless (exists $lookup_hash{$list1[0]}) { # Do something here } -------- # grep method unless (grep { $_ eq $list1[0] } @list2) { # Do something here }
In general, the hash is faster, but takes more memory.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
In reply to Re: ugly nested if's
by dragonchild
in thread ugly nested if's
by wilbur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |