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


In reply to Re: Syntax errors with {s by davido
in thread Syntax errors with {s by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.