I had been using SQL long before discovering Perl and became quite fond of the SQL *IN* operator. Not having found the equivalent in Perl, I usually construct a hash with my values as the keys. Unless something similar has already been done (and I have not discovered it yet), would this be something worth petitioning the Perl gods for?
# What I want to do if ($value == 1 or $value == 5 or $value == 21 or $value == 99){... # How I often do it: my %list = (1 => 1, 5 => 1, 21 => 1, 99 => 1); if ($list{$value}){... # Wouldn't something like this be better? if ($value IN (1, 5, 21, 99)){...
UPDATE: Thanks everyone. It looks like Quantum::Superpositions does what I had in mind (didn't find it initially searching CPAN). Since I'm still trying to fill the holes in my *swiss cheese* knowledge of Perl 5, I haven't looked into Perl 6 much.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: *IN* Operator for the Perl wish list
by davorg (Chancellor) on Mar 30, 2007 at 12:46 UTC | |
by Jenda (Abbot) on Mar 30, 2007 at 14:17 UTC | |
|
Re: *IN* Operator for the Perl wish list
by educated_foo (Vicar) on Mar 30, 2007 at 14:47 UTC | |
by liz (Monsignor) on Mar 30, 2007 at 16:31 UTC | |
by ysth (Canon) on Mar 30, 2007 at 17:33 UTC | |
by educated_foo (Vicar) on Mar 30, 2007 at 17:40 UTC | |
|
Re: *IN* Operator for the Perl wish list
by lidden (Curate) on Mar 30, 2007 at 12:49 UTC | |
by grinder (Bishop) on Mar 30, 2007 at 15:15 UTC | |
|
Re: *IN* Operator for the Perl wish list
by Limbic~Region (Chancellor) on Mar 30, 2007 at 12:48 UTC | |
by derby (Abbot) on Mar 30, 2007 at 15:12 UTC |