[Israel.pm] checking for presence of a value in a list

Levenglick Dov-RM07994 dovl at freescale.com
Wed Aug 15 07:01:35 PDT 2007


I don't remember all the details, however I seem to remember that there
was a module that gave hash functionality on array datatypes by
pre-tying them. I think that I read about it in in Damian's book. 


 
Best Regards,
Dov Levenglick
DSP SoC System and Applications Engineer,
Network and Computing Systems Group
Freescale Semiconductor Israel
Tel. +972-9-952-2804
The information contained in this email is classified as:
[ ] Freescale General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Proprietary
[x] Personal Memorandum

-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf Of Amir E. Aharoni
Sent: Wednesday, August 15, 2007 16:42
To: Perl in Israel
Subject: Re: [Israel.pm] checking for presence of a value in a list

On 15/08/07, Peter Gordon <peter at pg-consultants.com> wrote:
> @w = (1, 2, 3, 4, 5) ;
> grep { $w->{$_} ++ } @w ;
> print "found\n" if exists $w->{3} ;

Hmm, it's a nice Perlish trick, but to make it run under use strict, i
had to rewrite it like this:

my @w = qw(Reuven Shimon Levi Yehuda);
my $w = { };
grep { $w->{$_} ++ } @w;

print "found\n" if exists $w->{'Levi'};

... And that doesn't improve readability and maintainability. So this
would be too Perlish for production code that will have to be
maintained for years to come.

However, it can be OK, if it brings up a significant performance boost
... does it?
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list