&total calls a sub called total. You don't provide one. You could use sum from the module List::Util thus:
use warnings; use strict; use List::Util qw(sum); my @fred = qw{ 1 3 5 7 9 }; my $fred_total = sum(@fred); print "The total of \@fred is $fred_total.\n";
Prints:
The total of @fred is 25.
Update: Bugger, looks like I just answered a "homework" question! :)
In reply to Re: Undefined Subroutine
by GrandFather
in thread Undefined Subroutine
by clearsky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |