[PATCH perlfaq6] map in a void context.

[email protected] (Abigail)
Newsgroups perl.perlfaq.workers
Message-ID <[email protected]>
--- pod/perlfaq6.pod.orig       Tue Sep  9 10:23:50 2003
+++ pod/perlfaq6.pod    Tue Sep  9 10:27:44 2003
@@ -679,15 +679,18 @@
 hope to know on these matters (a full citation appears in
 L<perlfaq2>).

-=head2 What's wrong with using grep or map in a void context?
+=head2 What's wrong with using grep 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
+The problem is that grep builds 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.

+In perls older than 5.8.1, map suffers from this problem as well.
+But since 5.8.1, this has been fixed, and map is context aware - in void
+context, no lists are constructed.
+
 =head2 How can I match strings with multibyte characters?

 Starting from Perl 5.6 Perl has had some level of multibyte character
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.