>>>>> ""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. And I would have initialized the inner $i as follows: BEGIN { my $i = 20; sub iter { return ++$i } } print iter(); # 21 print iter(); # 22 Your example was more confusing than it needed to be. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/