develooper Front page | perl.beginners | Postings from June 2011

Re: Using $variable outside a foreach loop

Thread Previous | Thread Next
From:
shawn wilson
Date:
June 3, 2011 17:00
Subject:
Re: Using $variable outside a foreach loop
Message ID:
BANLkTi=m63NUW-vwA9xe3TaHCJoV0d4uPg@mail.gmail.com
On Jun 3, 2011 3:17 PM, "Uri Guttman" <uri@stemsystems.com> wrote:
>

>
> perl -le 'my $x = "zzz" ; for $x ( qw( foo bar ) ) { print "L: $x" } print
"E: $x"'
> L: foo
> L: bar
> E: zzz
>

That's odd, I would have thought that would have given 'foo bar bar'. So,
how would you keep data from a loop once you're outside of the loop?


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About