in reply to Re: Multiplying together the numers in an array
in thread Multiplying together the numers in an array

FWIW, here are a couple of variations on *= :
#!/usr/bin/perl -w use strict; use Benchmark qw(cmpthese); cmpthese( -5, { '*=' => sub { my @numbers = (2, 3, 4, 5); my $total = 1; $total *= $_ for @numbers; }, 'pop' => sub { my @numbers = (2, 3, 4, 5); my $total = pop @numbers; $total *= $_ for @numbers; }, 'shift' => sub { my @numbers = (2, 3, 4, 5); my $total = shift @numbers; $total *= $_ for @numbers; } } );
          Rate    *=   pop shift
*=    167004/s    --   -7%  -12%
pop   180190/s    8%    --   -5%
shift 188837/s   13%    5%    --