List::Util in your case is a module name, not an object.
Use "::" istead of "->".
my $sk = List::Util::sum(keys %h);
--
With best regards
Alexandr A Alexeev
http://web20.su/
Stanisław Findeisen пишет:
This short program:
#!/usr/bin/perl
use warnings;
use strict;
use List::Util qw(sum);
my %h = (1 => 5, 2 => 7, 5 => 18);
my $sk = List::Util->sum(keys %h);
my $sv = List::Util->sum(values %h);
print("Sum of keys: $sk\n");
print("Sum of values: $sv\n");
my @lk = (12, 3, 8);
my $lks = List::Util->sum(@lk);
print("Sum of lk: $lks\n");
yields the following output:
Argument "List::Util" isn't numeric in subroutine entry at ./test1.pl
line 9.
Argument "List::Util" isn't numeric in subroutine entry at ./test1.pl
line 10.
Sum of keys: 8
Sum of values: 30
Argument "List::Util" isn't numeric in subroutine entry at ./test1.pl
line 16.
Sum of lk: 23
What's wrong?
STF
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/