Hi Christopher,

Declarations within loops can be tricky.  I pretty much try to avoid them.  If I need 
a variable within any kind of loop, I declare it before entering the loop.  This may 
or may not be necessary, but it makes sense until or unless I am certain that, for 
instance while( my $Test++ < $Target) would not cause the interpreter to see a 
redeclaration with each pass.

Under any circumstances, not using strict is a false economy.  You only put off 
problems by doing so.  I found out the hard way, and had about a days work in 
correcting small tweaks that had not caused problems onm y system, but would not run 
on the server.  Using strict compilation makes this kind of problem less likely to 
occur.

Joseph

"Christopher D. Lewis" wrote:

> On Tuesday, January 7, 2003, at 09:02  PM, Peter Scott wrote:
> > You made a false economy by not using strict.  Yes, you would have to
> > fix those errors - mostly due to not declaring *everything* with
> > 'my'.  But to leave it out is to shoot yourself in the foot.
> >
> > You have managed to blow your whole leg off with a .22.
>
> I appreciate your keen eye for my nonsensical }s typo.  I had tried
> "use strict" in an earlier version, but got errors I could not
> decipher.  Adding back "use strict" and troubleshooting away some other
> errors, I get as error #1:
> "my" variable @rawRollArray masks earlier declaration in same scope at
> ./nudice-strict_test line 114.
>
> Line 114 (which now points to the right line, thank you so much!!) only
> shifts an element off of @rawRollArray, which has been declared as a
> "my" variable earlier on:
>
> my @rawRollArray = roll(@currentRollRequest);   # produces raw roll array
> from roll request array
> while @rawRollArray {
>         my $thisRoll = shift(@rawRollArray); # holds one die roll to be
> subjected to per-die min/max rules
> ...
> }
>
> Since I could make nothing of this sort of "error" I gave it up,
> looking instead for errors of which I could make some sense.  One way I
> sought to eliminate this was to eliminate all the "my" variables, which
> in turn required me to ditch "use strict" which began to complain
> mightily ... which is how I got a pile of (garbage) code with "use
> strict" commented out.  Can you direct me to a resource which will help
> me to see what needs to happen here?  From my cursory view, it seems
> any subsequent mention or use of a properly declared "my" variable will
> result in the error that it "masks earlier declaration in same
> statement at ..."
>
> Help!  What to do?
>
> Thanks again,
>         Chris
>
> --
> 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]

Reply via email to