in reply to Re^3: Lexical closures
in thread Lexical closures
It's not a bug; it was a deliberate design decision in (I believe) 5.004. Besides, you don't have to put my there. The aliasing works with global variables too:
use 5.010; package Foo; use vars '$i'; use strict; use warnings; sub bar { for $i (1 .. 10) { main::baz( $i ); } } package main; use strict; use warnings; use Test::More tests => 12; $Foo::i = 100; sub baz { my $expect = shift; is( $Foo::i, $expect ); } baz(100); Foo::bar(); baz(100);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Lexical closures
by backstab (Novice) on Oct 25, 2008 at 21:37 UTC | |
by ikegami (Patriarch) on Oct 25, 2008 at 22:33 UTC |