2009/9/28 Stanisław Findeisen <[email protected]>:
snip
> use List::Util qw(sum);
snip
> my @lk = (12, 3, 8);
> my $lks = List::Util->sum(@lk);
snip
> What's wrong?
snip
The arrow operator passes the thing on the left to the function on the
right, so
CLASSNAME->method();
is the same as
CLASSNAME::method("CLASSNAME");
Given that you imported the sum function, you should just say
my $lks = sum @lk;
If you don't want the sum function in your namespace (for instance if
you have your own sum function that behaves differently), you should
say
use List::Util;
my @lk = (12, 3, 8);
my $lks = List::Util::sum @lk;
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/