I checked my script using "perl -w -c" and get a "Global symbol "..." requires explicit package name" error. I am using strict and understand I need to explicitly define each variable. However, when I assign either "my" or "local" to the variables, I still get the same message. The error refers to @allquestions, $anslength, @allanswers on lines 22, 27, 28, 34, 45, 46. Below is the script. 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>"; local @allquestions = (@allquestions, $value); } if ($type =~ m/a/i) { # ** CHECKS FOR ANSWER LINE my @answers = split (/,/, $value); # ** SPLITS ANSWER LINE IN +TO ARRAY local $anslength = @answers; # ** LENGTH OF @ANSWERS local @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') . "&nbsp; &nbsp;"; print reset (-value=>'Reset answers'); print "</CENTER>"; print end_form; print end_html;

In reply to explicit package name by chriso

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.