FYI, for future searches, you can safely omit "perl" from "perl product" (what's next, "perl array" ? :)).
However, with the loop and all, it seems like a terribly inefficient method of doing such a thing. Anyone have a smarter way?
Why does it seem inefficient? It's the most straight forward way to accomplish the task.
Maybe not as "elegant" (matter of opinion) as
sub product {
my $list = shift;
my $prod = 1;
$prod *= $_ for @$list;
return $prod;
}
but it's pretty much as efficient as it gets.
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" |
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). |
** The third rule of perl club is a statement of fact: pod is sexy. |