Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Re: compilation errors???

by bikeNomad (Priest)
on Aug 22, 2001 at 09:10 UTC ( #106879=note: print w/ replies, xml ) Need Help??

in reply to Re: compilation errors???
in thread compilation errors???

You said:

while(<PAGES>) { push(@pages, $_); #semi colon added }
Perl doesn't care if there's a semicolon there. Generally it's OK not to have one at the end of a block.

But I'd say that the error messages from Perl are a bit cryptic from time to time; for a newbie, it can be somewhat hard to figure out what went wrong.

What you can do is to forget, first, that this is a CGI. Comment out the "use CGI::Carp" and put in instead

use Carp; use diagnostics;
and then run Perl in check-mode: perl -cw and look at the output. You'll get a moderately less cryptic output that starts:

Scalar value @filenames[$i] better written as $filenames[$i] at +line 71 (#1) (W syntax) You've used an array slice (indicated by @) to select a single element of an array. Generally it's better to ask for a sc +alar value (indicated by $). The difference is that $foo[&bar] always behaves like a scalar, both when assigning to it and when evaluati +ng its argument, while @foo[&bar] behaves like a list when you assign to +it, and provides a list context to its subscript, which can do weird t +hings if you're expecting only one subscript. On the other hand, if you were actually hoping to treat the array element as a list, you need to look into how references work, beca +use Perl will not magically convert between scalars and lists for you. + See perlref. Possible unintended interpolation of @filenames in string at lin +e 71. Scalar found where operator expected at line 72, near "] $title" + (#2) (S) The Perl lexer knows whether to expect a term or an operator. + If it sees what it knows to be a term when it was expecting to see an operator, it gives you this warning. Usually it indicates that an operator or delimiter was omitted, such as a semicolon. Global symbol "@pages" requires explicit package name at line 11 +. Global symbol "@filenames" requires explicit package name at lin +e 12. Global symbol "@titles" requires explicit package name at line 1 +3.

This should start you on your way to fixing the problem. The "Global symbol...requires explicit package name" can be cured by declaring your variables using my.

Comment on Re: Re: compilation errors???
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://106879]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2014-07-30 10:00 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (230 votes), past polls