Here's the error report (sorry for the wrapping):
Being trained from an early age on various "old school" compilers (MS Pascal version 1, for instance), generally one should avoid even looking at errors beyond the 1st or 2nd message, as they are usually caused by the earlier ones.C:\Perl\perl\BOD>perl -c bod_mask.pl "my" variable $rsp masks earlier declaration in same scope at bod_mask +.pl line 99. "my" variable $rsp_line masks earlier declaration in same scope at bod +_mask.pl line 99. "my" variable @bits masks earlier declaration in same scope at bod_mas +k.pl line 101. "my" variable $rsp masks earlier declaration in same scope at bod_mask +.pl line 101. "my" variable @bits masks earlier declaration in same scope at bod_mas +k.pl line 103. "my" variable $bit_index masks earlier declaration in same scope at bo +d_mask.pl line 103. "my" variable $time masks earlier declaration in same scope at bod_mas +k.pl line 105. "my" variable $space masks earlier declaration in same scope at bod_ma +sk.pl line 105. "my" variable @bits masks earlier declaration in same scope at bod_mas +k.pl line 105. syntax error at bod_mask.pl line 85, near ") (" Global symbol "$time" requires explicit package name at bod_mask.pl li +ne 85. Global symbol "$space" requires explicit package name at bod_mask.pl l +ine 85. Global symbol "$bits" requires explicit package name at bod_mask.pl li +ne 85. Global symbol "$bit_string" requires explicit package name at bod_mask +.pl line 86. syntax error at bod_mask.pl line 91, near ") {" syntax error at bod_mask.pl line 96, near "elsif" syntax error at bod_mask.pl line 106, near "}" bod_mask.pl had compilation errors.
Being short on coffee and contact solution, I stared at this for quite a while. Searching my ~100 line script, there was only one my declaration for each of these variables! [Calm down -- Perl isn't picking on you. Perl is doing the best it can, given the shoddy input you gave it. You must be doing something wrong -- think.]
The scope hint started to sink in, so I went looking for missing }s and )s, as this is one of my frequent failings. I found a missing ) on an if conditional, and tried again. Now there were more my errors!
Calming down somewhat (no, drugs were not involved, but thanks for asking), I decided to isolate sections of code to narrow down the search for the offending line(s). I prematurely ended a few blocks with }s, and deftly placed an __END__ to isolate the problem section:
OK, I've narrowed it down to a few lines of code. Careful checking of all {} and () pairs (thank you for small miracles and smart editors), I found another lopsided if conditional. Wala! Problem solved!C:\Perl\perl\BOD>perl -c bod_mask.pl bod_mask.pl syntax OK
But wait...Why did perl report all of those my errors, and not something more appropriate to missing )s?
It did, near the end:
Moral: If the first error message doesn't help you find the cause, check through more of them. After all, Perl doesn't stop at the first error message because that may not be the cause of the error.syntax error at bod_mask.pl line 91, near ") {"
Feel free to contribute your own D'oh moments from compiler message head scratching sessions.
Brought to you by your local chapter of the Perl Error Message Society.
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Grokking Compile Error Messages
by TimToady (Parson) on Jul 21, 2004 at 15:55 UTC | |
by hardburn (Abbot) on Jul 21, 2004 at 16:36 UTC | |
by QM (Parson) on Jul 21, 2004 at 17:28 UTC | |
by ambrus (Abbot) on Jul 21, 2004 at 22:20 UTC | |
by TimToady (Parson) on Jul 22, 2004 at 00:02 UTC | |
by mhi (Friar) on Jul 22, 2004 at 09:45 UTC | |
Re: Grokking Compile Error Messages
by BrowserUk (Patriarch) on Jul 21, 2004 at 16:34 UTC | |
Re: Grokking Compile Error Messages
by hardburn (Abbot) on Jul 21, 2004 at 15:54 UTC | |
by QM (Parson) on Jul 21, 2004 at 17:24 UTC | |
by FoxtrotUniform (Prior) on Jul 21, 2004 at 23:36 UTC | |
by Aristotle (Chancellor) on Jul 27, 2004 at 15:42 UTC | |
Re: Grokking Compile Error Messages (details)
by tye (Sage) on Jul 21, 2004 at 16:13 UTC | |
by QM (Parson) on Jul 21, 2004 at 17:45 UTC | |
Re: Grokking Compile Error Messages
by stvn (Monsignor) on Jul 21, 2004 at 17:51 UTC | |
by QM (Parson) on Jul 21, 2004 at 20:23 UTC | |
by greenFox (Vicar) on Jul 22, 2004 at 07:08 UTC | |
by BrowserUk (Patriarch) on Jul 22, 2004 at 09:39 UTC | |
Re: Grokking Compile Error Messages
by QM (Parson) on Jul 22, 2004 at 14:15 UTC |