cvs commit: perlfaq perlfaq6.pod
[email protected] (Robert Spier) 21 Sep 2003 06:02:10 -0000
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 03/09/20 23:02:10 Modified: . perlfaq6.pod Log: Sync from p5p Revision Changes Path 1.22 +10 -7 perlfaq/perlfaq6.pod Index: perlfaq6.pod =================================================================== RCS file: /cvs/public/perlfaq/perlfaq6.pod,v retrieving revision 1.21 retrieving revision 1.22 diff -u -w -r1.21 -r1.22 --- perlfaq6.pod 20 Sep 2003 06:38:54 -0000 1.21 +++ perlfaq6.pod 21 Sep 2003 06:02:10 -0000 1.22 @@ -1,6 +1,6 @@ =head1 NAME -perlfaq6 - Regular Expressions ($Revision: 1.21 $, $Date: 2003/09/20 06:38:54 $) +perlfaq6 - Regular Expressions ($Revision: 1.22 $, $Date: 2003/09/21 06:02:10 $) =head1 DESCRIPTION @@ -679,14 +679,17 @@ 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?