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

Is there a convenient means of finding unmatced brackets or braces in a script or module? I am looking at someone else's code. It doesn't compile due to a "Missing right curly or square bracket". I have been through the code numerous times but everything seems to match up. Is there are tool or utility that will parse a file and show you if/where mismatched brackets occur? Thanks.

Replies are listed 'Best First'.
Re: Finding unmatched brackets/braces
by Anonymous Monk on Feb 14, 2002 at 02:00 UTC
    You might try cperl-mode in emacs, or perltidy.

    --
    perl -pe "s/\b;([st])/'\1/mg"

      See, that's from getting redirected to www.perlmonks.org randomly. I posted (my sig is there afterall), but it went through www.perlmonks.org and hence shows an Anoynmous Monk.

      UPDATE: Would someone please enlighten me as to why this simple bug report (and the prior one) warrant a --? I don't care about the XP, but honestly, how does it warrant a--? The former node was in a thread *explicitly* about PM bugs since the move.

      --
      perl -pe "s/\b;([st])/'\1/mg"

Re: Finding unmatched brackets/braces
by Speedy (Monk) on Feb 14, 2002 at 01:49 UTC
    One of the joys of switching to Linux and using VI (and its enhancements vim and gvim) was learning that while one is in Command mode highlighting a paren, bracket, or brace and entering shift-% (both together) leads the cursor to hop to the matching paren, bracket, etc.

    Really helps track down some gremlins!