Rafael Garcia-Suarez wrote at Wed, 10 Sep 2003 14:00:05 -0700:

> -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.

It's still odd in logical.

If you want to do something _for_ every element, do it.
If you want to do a _map_ping of a list, do it.
But I won't suggest or remove the warning of the FAQ,
as it still emphasizes the right way and doesn't bring your program in
(might be serious) efficiency problems when working with an older Perl.


Greetings,
Janek

Reply via email to