Good tip, Peter, Joseph
Peter Scott wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Christopher D . Lewis) writes: > > > >On Tuesday, January 7, 2003, at 10:31 AM, Peter Scott wrote: > > > >> [EMAIL PROTECTED] (Christopher D . Lewis) writes: > >>> My problem is that the errors Perl coughs up end with: > >>> > >>> syntax error at ./nudice-01c line 187, near "sub displayResults " > >>> syntax error at ./nudice-01c line 305, near "sub rollRequest" > >>> syntax error at ./nudice-01c line 325, near "while @rawRollArray" > >>> syntax error at ./nudice-01c line 457, near "}" > >>> Execution of ./nudice-01c aborted due to compilation errors. > >>> > >>> This would be all well and good, except that every text editor I point > >>> at my program agrees that the actual line count ends at 304. > >>> > >>> Ideas? > >> > >> What line numbers do your text editors say the above statements are > >> actually on? > >> > >> Sprinkle a few > >> > >> print __LINE__; > >> > >> statements around and see what Perl thinks the line numbers are. > > > >I replaced the entirety of sub displayResults with: > > > >sub displayResults { print __line__ . "sub displayResults"; } > > That needs to be __LINE__, not __line__. The above is an error. > You do have -w and use strict in this program, right? > > >(both to get Perl's idea of the line numbers, and to implement another > >suggestion I replace contents of problem subroutines with simple code > >to track down bugs) > > > >and my errors went from: > >chris% ./nudice-01c > >"my" variable $labelThrow masks earlier declaration in same scope at > >./nudice-01c line 193. > >"my" variable @requests masks earlier declaration in same statement at > >./nudice-01c line 193. > >"my" variable $requestNumber masks earlier declaration in same > >statement at ./nudice-01c line 193. > >"my" variable $labelThrow masks earlier declaration in same scope at > >./nudice-01c line 195. > >"my" variable @requests masks earlier declaration in same scope at > >./nudice-01c line 195. > >"my" variable $requestNumber masks earlier declaration in same scope at > >./nudice-01c line 195. > >"my" variable $labelThrow masks earlier declaration in same scope at > >./nudice-01c line 197. > >"my" variable @requests masks earlier declaration in same scope at > >./nudice-01c line 197. > >"my" variable $requestNumber masks earlier declaration in same scope at > >./nudice-01c line 197. > >"my" variable @requests masks earlier declaration in same statement at > >./nudice-01c line 197. > >"my" variable $requestNumber masks earlier declaration in same > >statement at ./nudice-01c line 197. > >syntax error at ./nudice-01c line 187, near "sub displayResults " > >syntax error at ./nudice-01c line 305, near "sub rollRequest" > >syntax error at ./nudice-01c line 325, near "while @rawRollArray" > >syntax error at ./nudice-01c line 457, near "}" > >Execution of ./nudice-01c aborted due to compilation errors. > > > >to the more modest: > >chris% ./nudice-01c > >syntax error at ./nudice-01c line 187, near "sub displayResults " > >syntax error at ./nudice-01c line 189, near "sub rollRequest" > >syntax error at ./nudice-01c line 209, near "while @rawRollArray" > >syntax error at ./nudice-01c line 341, near "}" > >Execution of ./nudice-01c aborted due to compilation errors. > > I've got this feeling that you've done something fundamentally wrong in > your program, like using Pascal's BEGIN and END instead of curly braces > for subroutine code blocks :-) > > >So, now that I know all the variable problems are in displayResults > >despite the line numbers being off, I can start looking outside > >displayResults for the other errors. I note in passing that I can't > >find a bunch of "my labelThrow" masking one another, as in > >displayResults I make the label for each throw using: > > my $labelThrow; # Identifies throw type for table readers > > # Calculates Label for "Throw" > > $labelThrow .= $requests[$requestNumber]{"numDicePerThrow"} if > >$requests[$requestNumber]{"numDicePerThrow"} > 1; # Puts numDice in > >throw's label if > 1 > > $labelThrow .= "d" . $requests[$requestNumber]{"numSidesPerDie"}; # > >Puts Die size > > $labelThrow .= $requests[$requestNumber]{numAddedToThrow} if > >$requests[$requestNumber]{numAddedToThrow};#Puts numAddedToThrow in > >throw's labal if nonzero > > > >Does anyone spot what I'm doing wrong in trying to build a this label's > >contents in this way? > > Nothing. > > Send us a URL to the file itself. That'll avoid a large posting and also > line breaking issues. I have a suspicion you are barking up the wrong tree. > Showing us the code should reveal the problem in a matter of seconds. > > In general <plug>as I say in my book</plug>, when presented with a slew of > error messages, fix the first one and ignore the rest, since they are quite > possibly cascading and therefore will go away when the first one is fixed. > However, I still want to see how Perl gets these weird line numbers you > report. > > -- > Peter Scott > http://www.perldebugged.com > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]