develooper Front page | perl.beginners | Postings from September 2009

Argument "List::Util" isn't numeric

Thread Next
From:
Stanisław Findeisen
Date:
September 28, 2009 05:27
Subject:
Argument "List::Util" isn't numeric
Message ID:
4AC0AB95.8010408@gemius.pl
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About