--- Bob Mangold <[EMAIL PROTECTED]> wrote:
> Date: Tue, 19 Jun 2001 19:40:51 -0700 (PDT)
> From: Bob Mangold <[EMAIL PROTECTED]>
> Reply-to: [EMAIL PROTECTED]
> Subject: Re: variable losing it's value
> To: Michael Fowler <[EMAIL PROTECTED]>
> 
> But this still leaves the question of why the scope of $foo on the first line
> doesn't carry through to the foreach loop. Assuming that $foo was declared
> global, it's value is essentially unaffected by the foreach loop, even though
> without it the foreach loop wouldn't work (using strict).
> 
> I guess I just don't see why this one example is an exception to the entire
> concept of scope. In any other case the scope of a localized variable
> includes
> it's own blcok and any sub-block within that, but not in this case.
> 
> -Bob
> 
> > However, regardless of whether or the iterator has always been localized,
> > the foreach syntax -has- made it easier to localize a variable.  Consider:
> > 
> >     use strict;
> > 
> >     my $foo;
> >     foreach $foo (...) { ... }
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to