You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jason Bodnar <jb...@tivoli.com> on 2000/02/16 21:08:17 UTC

RE: Seems like it should be simple...

Try 'my' instead of 'local'.

On 16-Feb-00 J. Meltzer wrote:
> I am just getting started with mod_perl (Apache 1.3.11,mod_perl 1.21,AIX 
> 4.3.3), and I am trying to convert some of my CGI scripts to use the Apache 
> API.  This is also my first try at using strict, and I keep running into 
> the following error:
> 
> Global symbol "$nbateam" requires explicit package name at sports.cgi line
> 59.
> Variable "$nbateam" is not imported at sports.cgi line 59.
> 
> This error shows up for a LOT of my variables.  I have tried declaring the 
> variables at the start of the script with
> local ($nbateam);
> 
> but the same error occurs.  When I looked at the mod_perl guide, the only 
> reference to this said that "ou should not use variables that have not been 
> defined first".  All well and good, but what exactly constitutes "defining 
> a variable" when the first mention of that variable gives the error shown 
> above?
> 
> The latest try of my code looks like this:
> 
> use LWP::Simple;
> use CGI qw(:standard);
> use Time::CTime;
> use strict;
> 
> require "./hashdata.pl";
> 
> local (%nhllist,%nbalist,%nfllist,%mlblist,%regions) = {};
> local (@reglist,@nhllist,@nbalist,@nfllist,@mlblist) = [];
> local (@nhlteam,@nbateam,@mlbteam,@nflteam,@region) = [];
> local ($R1,$R2,$R3,$R4,$R5) = "";
> local ($nhlteam,$nbateam,$nflteam,$mlbteam,$region) = "";
> local @today = split(/ /,strftime("%Y%m%d %Y %D",localtime(time)));
> local $now = strftime("%r %Z %B %o %Y",localtime(time));
> local $oneday = 3600*24;
> 
> I then go on to use all of the variables given above.  I originally tried 
> the first five "local" lines without the = signs or the symbols to the 
> right of the = signs, but that did not work either.
> 
> The error that gets generated is (in part):
> 
> Subroutine head redefined at /usr/local/lib/perl5/5.00503/CGI.pm line 234.
> Prototype mismatch: sub main::head ($) vs none at 
> /usr/local/lib/perl5/5.00503/CGI.pm line 234.
> 
> -- if anyone can help with the two above lines, that would be cool too.
> 
> Global symbol "%nhllist" requires explicit package name at sports.cgi line
> 14.
> Global symbol "%nbalist" requires explicit package name at sports.cgi line
> 14.
> Global symbol "%nfllist" requires explicit package name at sports.cgi line
> 14.
> Global symbol "%mlblist" requires explicit package name at sports.cgi line
> 14.
> Global symbol "%regions" requires explicit package name at sports.cgi line
> 14.
> Global symbol "@reglist" requires explicit package name at sports.cgi line
> 15.
> Variable "@nhllist" is not imported at sports.cgi line 15.
> Global symbol "@nhllist" requires explicit package name at sports.cgi line
> 15.
> Variable "@nbalist" is not imported at sports.cgi line 15.
> Global symbol "@nbalist" requires explicit package name at sports.cgi line
> 15.
> Variable "@nfllist" is not imported at sports.cgi line 15.
> Global symbol "@nfllist" requires explicit package name at sports.cgi line
> 15.
> Variable "@mlblist" is not imported at sports.cgi line 15.
> Global symbol "@mlblist" requires explicit package name at sports.cgi line
> 15.
> Global symbol "@nhlteam" requires explicit package name at sports.cgi line
> 16.
> Global symbol "@nbateam" requires explicit package name at sports.cgi line
> 16.
> Global symbol "@mlbteam" requires explicit package name at sports.cgi line
> 16.
> Global symbol "@nflteam" requires explicit package name at sports.cgi line
> 16.
> Global symbol "@region" requires explicit package name at sports.cgi line 16.
> Global symbol "$R1" requires explicit package name at sports.cgi line 17.
> Global symbol "$R2" requires explicit package name at sports.cgi line 17.
> Global symbol "$R3" requires explicit package name at sports.cgi line 17.
> Global symbol "$R4" requires explicit package name at sports.cgi line 17.
> Global symbol "$R5" requires explicit package name at sports.cgi line 17.
> Variable "$nhlteam" is not imported at sports.cgi line 18.
> Global symbol "$nhlteam" requires explicit package name at sports.cgi line
> 18.
> Variable "$nbateam" is not imported at sports.cgi line 18.
> Global symbol "$nbateam" requires explicit package name at sports.cgi line
> 18.
> Variable "$nflteam" is not imported at sports.cgi line 18.
> Global symbol "$nflteam" requires explicit package name at sports.cgi line
> 18.
> Variable "$mlbteam" is not imported at sports.cgi line 18.
> Global symbol "$mlbteam" requires explicit package name at sports.cgi line
> 18.
> Variable "$region" is not imported at sports.cgi line 18.
> Global symbol "$region" requires explicit package name at sports.cgi line 18.
> Global symbol "@today" requires explicit package name at sports.cgi line 19.
> Global symbol "$now" requires explicit package name at sports.cgi line 20.
> Global symbol "$oneday" requires explicit package name at sports.cgi line 21.
> 
> Please, if someone could clearly explain the way to avoid these errors 
> (without telling "strict" not to look at variables), or point me to a clear 
> explanation, I would be very grateful.
> 
> Thank you,
> 
> Jonathan

---
Jason Bodnar + jbodnar@tivoli.com + Tivoli Systems

I swear I'd forget my own head if it wasn't up my ass. -- Jason Bodnar