[Israel.pm] Is there an operator like IN in perl

Amir E. Aharoni amir.aharoni at gmail.com
Wed Mar 4 06:29:17 PST 2009


2009/3/4 Avishalom Shalit <avishalom at gmail.com>:
> also, i don't agree that the hash makes the code look weird.
>> my %beatles = (
>>    John => 'guitar',
>>    Paul => 'bass',
>>    George => 'sitar',
>>    Ringo => 'drums',
>> );
>
>> my %beatles ;
>>$beatles{$_}='x' for  qw/john paul george ringo/;

It works, but *sometimes* the code maintainer will wonder what this
"x" stands for. (A comment saying that it's just a dummy will solve
this.)

But all in all, the hash solution is quite elegant.

-- 
Amir Elisha Aharoni

heb: http://haharoni.wordpress.com | eng: http://aharoni.wordpress.com
cat: http://aprenent.wordpress.com | rus: http://amire80.livejournal.com

"We're living in pieces,
 I want to live in peace." - T. Moore



More information about the Perl mailing list