Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: RE: Re: Array to Hash

by Sihal (Pilgrim)
on Nov 19, 2002 at 17:17 UTC ( [id://214193]=note: print w/replies, xml ) Need Help??


in reply to RE: Re: Array to Hash
in thread Array to Hash

What is so bad about map in map in void context ? I mean no harm can be done, can it ?

Replies are listed 'Best First'.
Re: Re: RE: Re: Array to Hash
by Tomte (Priest) on May 13, 2003 at 12:42 UTC

    Just in case others Super Search for an answer to this question and follow merlyns node mentioned first in the result-set, here is the relevant excerpt of the perlfaq6

    Found in /usr/lib/perl5/5.8.0/pod/perlfaq6.pod
    What's wrong with using grep or map in a void context?

    The problem is that both grep and map build a return list, regardless of the context. This means you're making Perl go to the trouble of building a list that you then just throw away. If the list is large, you waste both time and space. If your intent is to iterate over the list then use a for loop for this purpose.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://214193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-18 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found