develooper Front page | perl.perl5.porters | Postings from March 2000

bug or not ?

Thread Next
Graham Barr
March 17, 2000 09:55
bug or not ?
Message ID:
I am not sure if this is a bug or not.

my $x = 1;
$clo = sub { print "closure ",$x,"\n"; };
for $x (qw(a b)) {
  print "for ",$x,"\n";


for a
closure 1
for b
closure 1

which  is what I would expect if there was a my in the for statement.
However if $x is a package variable, you get

for a
closure a
for b
closure b


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About