The stupid question is the question not asked | |
PerlMonks |
Re: returning scalar context from map or grepby BrowserUk (Patriarch) |
on Apr 28, 2003 at 13:33 UTC ( [id://253680]=note: print w/replies, xml ) | Need Help?? |
Now you know how to do it, you might think twice about whether you should do it? Using map or grep to retrieve a single value is just as bad as using it in a void context I think. Your still building a (potentially large) list, only to discard all but one of the values. I do it myself on occasion, so I'm not waving a big stick, but it's worth thinking about the cost when you do it. Actually, it may be even worse as I seem to recall that they had been 'fixed' to not bother building the return list in a void context? I could be wrong on that. Examine what is said, not who speaks.
1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong. 2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible 3) Any sufficiently advanced technology is indistinguishable from magic. Arthur C. Clarke.
In Section
Seekers of Perl Wisdom
|
|