> -----Original Message----- > From: drieux [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 3:01 PM > To: cgi cgi-list > Subject: Re: Counting the elements of an array > > > > On Monday, May 20, 2002, at 08:13 , Bob Showalter wrote: > >> -----Original Message----- > >> From: drieux [mailto:[EMAIL PROTECTED]] > >> > >> #------------------------ > >> # > >> sub haveMap { > >> my (@list) = @_; > >> my %seen = (); > >> > >> map {$seen{$_}++} @list; > > > > So, is the old saw about "don't use map() in a void context" out > > the window? > > you will have to explain this 'old saw' to 'this old dog' > as this is the first time I have heard it....
perldoc -q 'What's wrong with using grep or map in a void context?' says: Both grep and map build a return list, regardless of their context. This means you're making Perl go to the trouble of building up a return list that you then just ignore. That's no way to treat a programming language, you insensitive scoundrel! perldoc perlstyle says: o Avoid using grep() (or map()) or `backticks` in a void context, that is, when you just throw away their return values. Those functions all have return values, so use them. Otherwise use a foreach() loop or the system() function instead. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]