in reply to Missing right curly or square bracket at jsdisp.cgi line 178, at end of line syntax error at jsdisp.cgi line 178, at EOF

Are you sure that the code you posted gives the error you've described? When I run it I get a message about the failure to export a function called "warningsToBrowsers", and compilation aborts. That's because the function is called "warningsToBrowser" (not Browsers).

When I fix that typo, I get some other compiletime errors such as:

Software error: syntax error at mytest.pl line 31, near "){" syntax error at mytest.pl line 89, near "}" mytest.pl had compilation errors.

The first error is because you're missing a semicolon ";" at the end of line 29.

The second error also goes away when you fix line 29, but then you'll get a message related to the fact that you're also missing a semicolon at the end of line 96. Fix that one and your script will at least compile.

Semicolons at the end of statements are as important as closing quotes and curly brackets. If one is missing, Perl doesn't know where one sentence ends and the next begins. This throws the compiler off, and you'll get error messages that misreport the errant line number, because the problem isn't detected at the point where you forgot the semicolon, it's detected at the point where Perl realizes you've forgotton something. ...that can be a few lines after the mistake.

Updated: By the way, you probably don't need to be testing for definedness of @arr. It usually is correct to test whether @arr has elements: "if( @arr ) { ....". The documentation for defined explains:

Use of defined on aggregates (hashes and arrays) is deprecated. It used to report whether memory for that aggregate has ever been allocated. This behavior may disappear in future versions of Perl. You should instead use a simple test for size:

if (@an_array) { print "has array elements\n" } if (%a_hash) { print "has hash members\n" }

Update2: One last little piece of advice that I'm not sure has been made clear yet: When Perl gives you an error message, if when you look on the line Perl reports as being in error you don't see anything wrong, scan back (or up) in the script a few lines. It's often the result of something you did wrong in a previous line.


Dave

  • Comment on Re: Missing right curly or square bracket at jsdisp.cgi line 178, at end of line syntax error at jsdisp.cgi line 178, at EOF
  • Select or Download Code