clearsky has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone...
I’m trying to run the following simple code but I keep getting the error message: Undefined subroutine &main::total called at p67-1 line 4.
I’ve been trying for hours to understand why and I’m stumped. Can anyone give me a hand?
The Perl version I’m using is 5.8.1. and the code came from p.67 of Learning Perl, Schwartz, Phoenix and Foy.
Thank you, John.
#!/usr/bin/perl -w use strict; my @fred = qw{ 1 3 5 7 9 }; my $fred_total = &total(@fred); print "The total of \@fred is $fred_total.\n"; print "Enter some numbers on separate lines: "; my $user_total = &total(<STDIN>); print "The total of those numbers is $user_total.\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Undefined Subroutine
by merlyn (Sage) on May 19, 2006 at 22:50 UTC | |
by K_M_McMahon (Hermit) on May 20, 2006 at 07:34 UTC | |
by Anonymous Monk on May 19, 2006 at 23:44 UTC | |
Re: Undefined Subroutine
by japhy (Canon) on May 19, 2006 at 22:51 UTC | |
by clearsky (Initiate) on May 19, 2006 at 23:46 UTC | |
Re: Undefined Subroutine
by GrandFather (Saint) on May 19, 2006 at 22:55 UTC | |
by clearsky (Initiate) on May 19, 2006 at 23:47 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |