chriso has asked for the wisdom of the Perl Monks concerning the following question:
Global symbol "@allquestions" requires explicit package name at makequiz.cgi line 22 and line 46.
Global symbol "$anslength" requires explicit package name at makequiz.cgi line 27 and line 34.
Global symbol "@allanswers" requires explicit package name at makequiz.cgi line 28 and line 45.
I have tried placing "my" and "local" in front of these but I still get the same message. What does it mean and how do I fix it? Thanks.
#!/usr/bin/perl #c:\sambar50\perl\perl.exe use CGI qw(:standard); use strict; use warnings; print header; local $/ = "~\n"; # *** CHANGES INPUT RECORD SEPARATOR TO ~line brea +k print start_html (-title=>'quiz', -BGCOLOR=>'beige'); print start_form (-method=>'POST', -action=>"http://localhost/cgi-bin/ +gradequiz.cgi"); my $file = param('file'); open (FILE, $file) || die "Cannot open $file: $!"; while (<FILE>) { # ** READS EACH LINE OF TEXT FROM FILE chomp; # ** BY DEFAULT, CHOMPS OFF $/ FROM EACH LINE my ($type, $value) = split (/:/, $_); # ***** SPLITS EACH LINE BY +TYPE AND CONTENT if ($type =~ m/q/i) { # ** CHECKS FOR QUESTION LINE & PRINTS QUESTI +ON print "<B>$value</B><BR>"; @allquestions = (@allquestions, $value); } if ($type =~ m/a/i) { # ** CHECKS FOR ANSWER LINE my @answers = split (/,/, $value); # ** SPLITS ANSWER LINE IN +TO ARRAY $anslength = @answers; # ** LENGTH OF @ANSWERS @allanswers = (@allanswers, $value); } #** CHECKS FOR SELECTION LINE AND if ($type =~ m/^s/) { # ** TYPE OF ANSWER BOX my %selections = split (/,/, $value); my @options = keys (%selections); if ($anslength > 1) { # ** DETERMINES TO USE RADIO OR CHECKB +OX print checkbox_group(-name=>$type, -values=>\@options, -linebre +ak=>'true', -labels=>\%selections); }else { print "<BR>"; print radio_group(-name=>$type, -values=>\@options, -linebre +ak=>'true', -labels=>\%selections, -default=>'-'); } print "<BR><HR><BR>"; } # END IF STATEMENT } # ** END WHILE STATEMENT close (FILE); print hidden(-name=>"answers", -default=>\@allanswers); print hidden(-name=>"questions", -default=>\@allquestions); print "<CENTER>"; print submit (-value=>'Grade') . " "; print reset (-value=>'Reset answers'); print "</CENTER>"; print end_form; print end_html;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is an
by dragonchild (Archbishop) on Dec 17, 2001 at 20:14 UTC | |
by Anonymous Monk on May 04, 2005 at 06:11 UTC | |
|
Re: What is an
by fuzzysteve (Beadle) on Dec 17, 2001 at 20:10 UTC |