On 8/18/07, Randal L. Schwartz <[EMAIL PROTECTED]> wrote: > >>>>> ""Chas" == "Chas Owens" <[EMAIL PROTECTED]> writes: > > "Chas> { > "Chas> my $i; > "Chas> sub iter { return $i++ } > "Chas> } > > "Chas> my $i = 5; > "Chas> print iter(), "\n"; > "Chas> print iter(), "\n"; > "Chas> print iter(), "\n"; > "Chas> print iter(), "\n"; > > I get it now, I think. I'm not sure why you put "my $i = 5" in there, > since that's unrelated to the $i of the closure.
The" my $i = 5;" was to show that the two variables named $i were indeed in different scopes. The expected out was 0 through 3. I probably should have put some comments in explaining that. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/