in reply to Re: Error msg "requires explicit package name"
in thread Error msg "requires explicit package name"

I can't try it till tomorrow when I get to work, sgifford, but if it does, I'm going to be mightily embarrassed. :-(

I notice that you did not use 'my' for all instances of $counter. I thought that was part of the requirements for using 'my'. At least I think that's the way I've seen it used. (I think - now I'm not sure of anything)

One other thing I see now is that the comments '#odd rows' and '#even rows' should have said columns, not rows.

  • Comment on Re: Re: Error msg "requires explicit package name"

Replies are listed 'Best First'.
Re: Re: Re: Error msg "requires explicit package name"
by sgifford (Prior) on Jun 17, 2003 at 06:42 UTC
    No, my is a variable declaration and should only be used the first time a lexical variable is referenced. Using two my's in the same scope creates two variables, and with -w will give this warning:
    "my" variable $i masks earlier declaration in same scope
    
    The reason you may see it more than once on the same variable is because the variable is being created new every time. For example:
    for(my $i=0;$i<10;$i++) { print $i,"\n"} for(my $i=9;$i>=0;$i--) { print $i,"\n"}
    uses two completely different $i variables that happen to have the same name, because the scope of $i is only inside the loop.

    Maybe that just confused you more, but hope it's helpful! :-)