On Oct 23, Frank Bax said:

At 02:11 PM 10/23/05, John W. Krahn wrote:

Frank Bax wrote:

> my $aval=''; map { $aval=$aval.sprintf("%4d",$aSuit{$a}{$_}); } @f_seq; > my $bval=''; map { $bval=$bval.sprintf("%4d",$aSuit{$b}{$_}); } @f_seq;

You shouldn't use map in void context, you should use a foreach loop

What is "void context"?

"Void context" means an expression whose return value is being discarded.

  $x = foo();  # scalar context
  @y = foo();  # list context
  foo();       # void context

map() builds a list to be returned, and by not USING its return value (that is, calling map() in void context), you're wasting resources. If you do

  map BLOCK LIST

and don't intend on saving the return value of map(), just use a for loop.

  for (LIST) BLOCK

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to