in reply to Scoping Problem
In my $year = --$year;the decrement operator is changing the $year in the OUTSIDE scope, then assigning it to the lexical $year in the INSIDE scope (which is the one that your print statement in BLOCK4 sees). Remember, until that statement finishes successfully, the INNER $year doesn't exist.
You could get the behavior you're looking for with: my $year = $year - 1;which doesn't change the value of the OUTER $year.
Update
Added example in second para.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Scoping Problem
by nimdokk (Vicar) on Jun 25, 2003 at 19:02 UTC |