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

Hello my friends,

Iīm having a very strange error. After a few editions on a script, wich included commands I am quite familiar with, Perl started complaining about things that just donīt make any sense.

For example: (code / error)

my $query3 = "insert into details (rec_id,descr,cover) VALUES ('$db_rec_id','$descr','$namecover');";
Error: Unquoted string "descr" may clash with future reserved word at C:\Andre\EstanteVirtual\Site\cgi-bin\adicionar.cgi line 440. Bareword found where operator expected at C:\Andre\EstanteVirtual\Site\cgi-bin\adicionar.cgi line 441, near ")VALUES" Fri Feb 25 21:04:04 2005 adicionar.cgi: (Missing operator before VALUES?)

Another one:

print $q->redirect( -url => "$dominio/cgi-bin/estante.cgi?aba=3");
Error: Scalar found where operator expected at C:\Andre\EstanteVirtual\Site\cgi-bin\adicionar.cgi line 490, at end of line Fri Feb 25 21:04:04 2005 adicionar.cgi: (Might be a runaway multi-line "" string starting on line 477)

The script generates two pages of these psycho complaints. All the suggestions that Perl gives donīt make sense. Any of you has run with this oddity already?

Im totally stuck with this.

Thanks a lot!

André

Replies are listed 'Best First'.
Re: ODD: Perl started complaining about just everything
by jZed (Prior) on Feb 26, 2005 at 00:29 UTC
    I'd look for a missing quote delimiter (like you forgot to end a string with a quote mark) or a missing semicolon. When you drop a quote mark or a semicolon, perl can get awfully confused about everything else.
Re: ODD: Perl started complaining about just everything
by kvale (Monsignor) on Feb 26, 2005 at 00:34 UTC
    A good strategy for dealing with puzzling errors like these is to perform a diff between the last version that didn't have the errors and the first version that had the errors. Diffs allow the you to concentrate on just the changes that broke your code.

    -Mark

Re: ODD: Perl started complaining about just everything
by betterworld (Curate) on Feb 26, 2005 at 01:19 UTC
    I'd try to comment huge parts of the code out, until Perl stops complaining. The remaining code need not make sense, you only have to make sure it contains no syntax errors. (update: use perl -c for this!) Then re-add the code step by step so you can find the source of the trouble.
Re: ODD: Perl started complaining about just everything
by chas (Priest) on Feb 26, 2005 at 03:28 UTC
    I've sometimes gotten some extremely cryptic error messages that turned out to be due to invisible characters in the text of my script. E.g., if I edited on a Windows machine and then put the script on a Linux system the extra return characters caused errors in some cases. Copying and pasting code sometimes puts things like tabs that you can't see into the code. That probably isn't the problem, but it's worth looking at your code in an editor using binary mode just to see. (That just occurred to me because you said "After a few editions on a script...")
    chas
Re: ODD: Perl started complaining about just everything
by fizbin (Chaplain) on Feb 26, 2005 at 11:54 UTC
    Look at the first of the psycho complaints, and then look backwards for an unmatched double quote mark ("). The first complaint, about the unquoted bareword, can only happen if perl thinks that descr is outside a string; therefore, it must think that there's some long string that ends with my $query3 = ".
    -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
Re: ODD: Perl started complaining about just everything
by graff (Chancellor) on Feb 26, 2005 at 22:13 UTC
    It looks like you're using DBI and CGI. If so, then apart from watching for mismatched quotes, as others have pointed out, you should probably reduce the amount of quoting overall (and increase the safety/reliability of the script) by using "?" placeholders in the query strings, and passing the variables as parameters when you execute:
    my $query3 = "insert into details (rec_id,descr,cover) VALUES (?,?,?);"; my $sth3 = $dbh->prepare( $query3 ); $sth3->execute( $db_rec_id, $descr, $namecover );
Re: ODD: Perl started complaining about just everything
by trammell (Priest) on Feb 26, 2005 at 15:10 UTC
    What editor are you using? If you can find one that handles syntax highlighting for Perl, the problem may become more obvious.