Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find unmatched {} 4

Status
Not open for further replies.

netman4u

Technical User
Mar 16, 2005
176
US
Hello all,

I have a very large program (greater 1000 lines) and I suspect that somewhere in my program there is an unmatched brace and it is messing it up. While does run, the results are not what I expect and I suspect teh missing brace may be the problem. I have a good editor that does brace matching, but I thought someone may know of a script you can run or something to help.

Thanks
 
If the perl compiler isn't telling you that you have an unmatched brace, I'd suspect something else.
 
Missing braces can be difficult to track down. You will most likely have to step through the script visually to check that all the braces are correct. 1000 lines should not take long to check visually, 10-15 minutes maybe, but it is tedious.
 
if you use warnings (maybe with -w too)

the error you get when you forget a '}' is like this
Code:
Missing right curly or square bracket at sample.pl line 1720, at end of line
syntax error at sample.pl line 1720, at EOF
Execution of sample.pl aborted due to compilation errors.
If you don't get a message like this then you have a problem with you perl.

The only editor that tells you if you have errors while you writting the script is Komodo[/LINK] [red](which is not free)[/red] underlining the line where the error is.

Some others, like [url=http://www.jedit.org] jEdit[/LINK] [blue](which is free)[/blue] when you click next to a '[' or '{' or '(' it matches the closest pair(showing a line connecting the two parts of the pair), if you dont see a line then this is an unmatched one.

But as KevinADC said, should not take long to check visually. Thats why writting a clean understandable code is such a big deal.

TIMTOWTDI
 
fyi, I'm pretty sure Eclpise EPIC does realtime syntax checking, though I only used it briefly.

________________________________________
Andrew

I work for a gift card company!
 
Perl Builder also does semi-realtime error checking, and does do {} bracket checking, although no editor I have used can find the exact location of a missing {} if they all match but one is just in the wrong place.
 
EPIC just runs perl -c on the displayed code after X seconds of inactivity and parses the error, so it's only as good as perl as far as what it reports. If it could say "missing brace on line X" then the brace wouldn't really add any semantic value to the code and wouldn't really be needed anyway.

________________________________________
Andrew

I work for a gift card company!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top