in reply to Undefined Subroutine

&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! :)


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Undefined Subroutine
by clearsky (Initiate) on May 19, 2006 at 23:47 UTC
    Thank you, Grandfather.