Rob Dixon wrote:
> 
> "Michael Kelly" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 
> > # print out all the captured numbers
> > map{ print "$_\n"; } @numbers;
> 
> Hi Michael.
> 
> May I warn against using 'map' in a void context like this? It'll work,
> sure, but you're using it for the side-effect of evaluating the 'print'
> expression. map's purpose is to 'translate' one list into another, and here
> it is faithfully producing a list of (presumably) 'true' values to indicate
> print's success in outputting each array element. This list occupies memory,
> may be huge, and just gets discarded. Better to use 'foreach' like this:
> 
>    print "$_\n" foreach @numbers;

Or just print the list that map produces.

print map { "$_\n" } @numbers;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to