adriang has asked for the wisdom of the Perl Monks concerning the following question:
Hi all I realy don't understand why I dont get "Global symbol "%CS101" requires explicit" when I run:
#!/usr/bin/perl # use warnings; use strict; use Carp; use 5.016; ave(); my %CS101 =("Joe Below" => 100, "Dan Gold" => 90, "Jon Kery" => 40, "Elton Jon" => 60, ); sub ave { foreach (keys %CS101) { print $CS101{$_}, "\n"; } } 1; __END__
It only wotks if I put the hash at the top. Thanks in advance. Adrian
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: subroutine no error
by Anonymous Monk on Jul 23, 2014 at 10:53 UTC | |
by adriang (Sexton) on Jul 24, 2014 at 06:08 UTC | |
|
Re: subroutine no error
by AppleFritter (Vicar) on Jul 23, 2014 at 10:27 UTC | |
by adriang (Sexton) on Jul 23, 2014 at 10:31 UTC | |
by AppleFritter (Vicar) on Jul 23, 2014 at 10:40 UTC | |
by adriang (Sexton) on Jul 23, 2014 at 10:51 UTC |