in reply to Syntax errors with {s

Others have mentioned that you're just missing a couple closing brackets. That's accurate. I just wanted to mention some tricks (good sound principles actually) that you can use to avoid this problem in the future.

First (and this has already been mentioned but deserves more attention), develop a style where it's easy to spot mismatched brackets of all kinds. Your example code is getting there, but it let you down still. I kind of like cuddled brackets like this:

if (...) { #stuff } else { #more stuff. }

...or...

if ( .... ) { if ( ... ) { # stuff } else { # more stuff } }

To me that keeps it pretty clear, but everyone has their own minor variations on such themes. Consistancy helps.

Another thing to try is a syntax-highlighting editor. Well-done syntax highlighting will help you to see when brackets don't match. The editor I use actually draws a little dotted line between matching brackets whenever my cursor is resting on a bracket. If the line doesn't lead anywhere, I can quickly see that's where I've got a problem (I use SciTE, which I think you can Google for. Other good (and possibly better) editors will have other techniques that help. But a good editor really can be a step in the right direction. Once you become familiar with the editor, it's easy to look at a piece of code and see where the syntax highlighting looks messed up. ...and that's where you can focus your efforts.

Another technique is to just test-compile the script. This is very helpful when you're working in a CGI environment where it may otherwise take several steps to get at the error messages. To test compile code, and see what errors the trial compilation may be generating, you can, at the command line, type: perl -c scriptname

Doing that will get Perl to attempt to compile the script, and if there's a problem, you'll see the errors immediately, rather than having to sift through webserver error logs.

Hope these tips help...


Dave