jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

Online I get: Software error: Execution of menu.pl aborted due to compilation errors. The code was working until I added
my $pass = $q->param('pass'); if ($pass ne "jerry"){ print "Content-type: text/html\n\n"; print "<HTML> \n"; print "The menu for tonight is \n"; print $words; print ". \n"; print "Hey bub, stop messin' with my menu!"; die; }

Here is the rest of the code does anyone see what is causing the error?
TIA
jg
#!/usr/bin/perl -w use strict; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser /; my $q = CGI->new(); # Parse Form Search Information # if it's a single form value, map the value as a scalar, other wise, +the value is # and arrayref my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param($_) } param(); my $pass = $q->param('pass'); if ($pass ne "jerry"){ print "Content-type: text/html\n\n"; print "<HTML> \n"; print "The menu for tonight is \n"; print $words; print ". \n"; print "Hey bub, stop messin' with my menu!"; die; } my $words = $q->param('words'); if ($words eq ""){ $words = "no specials today"; } open (TEXTFILE,"+>/home/nolaflash/www/menu.txt") || die "where's the d +amn file? : $!"; print TEXTFILE "words="; print TEXTFILE $words; close (TEXTFILE) || die "close damn you : $!"; print "Content-type: text/html\n\n"; print "<HTML> \n"; print "The menu has been updated for you. \n"; print "The menu for tonight is \n"; print "$words. \n";

Replies are listed 'Best First'.
Re: Local tests reveal no syntax error but...
by thraxil (Prior) on Sep 14, 2001 at 23:55 UTC

    try running your script from the command line to see what error the parser is finding.

    in your case, it's that the chunk you added uses $words before you declare it with my():

    Global symbol "$words" requires explicit package name at jerry.pl line + 21.

    anders pearson

      Yeah, I know about that part it does that when it is working too, I thought using my took care of the prob, especially since the script *was* working online with strict before I added the password block. jg
        Howdy!

        nononono...

        The snippet you added refers to "$word" *before* you get to the line that says "my $word".

        That first reference is using the global $word.

        Try inserting "my $word;" before the snippet you added.

        yours,
        Michael

Re: Local tests reveal no syntax error but...
by lemming (Priest) on Sep 15, 2001 at 00:06 UTC

    Try placing your new code after:

    my $words = $q->param('words');
    instead of before since you want to use $words inside the if statement.

Re: Local tests reveal no syntax error but...
by dragonchild (Archbishop) on Sep 14, 2001 at 23:49 UTC
    This is going to sound stupid, but does it work if you comment out everything you think you added? Oftentimes, we'll change "just one thing from A to B and they're obviously identical", and forget we did. I run into that a lot. *frowns*

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Well, it works when I cut the part I mentioned out so that should have same effect as commenting it out right? jg
Re: Local tests reveal no syntax error but...
by Dr. Mu (Hermit) on Sep 16, 2001 at 00:00 UTC
    Are you sure you want it to die when it's finished? I know you said "compilation errors", but it may still be worthwhile replacing die with exit, i.e. doing a normal termination instead of an abnormal one.