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";
In reply to Undefined Subroutine by clearsky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |