in reply to Re: Inlining a "lexically-scoped scalar which has no other references"
in thread Inlining a "lexically-scoped scalar which has no other references"
That's cool:
perl -MO=Deparse -e"BEGIN{ my $x = 12345; *Foo = sub(){ $x } }; print +Foo" sub BEGIN { my $x = 12345; *Foo = sub () { $x; } ; } print 12345; -e syntax OK
But why is the BEGIN block necessary?:
perl -MO=Deparse -e"{ my $x = 12345; *Foo = sub(){ $x }; } print Foo() +" { my $x = 12345; *Foo = sub () { $x; } ; } print Foo(); -e syntax OK
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Inlining a "lexically-scoped scalar which has no other references"
by ikegami (Patriarch) on Sep 28, 2009 at 05:21 UTC | |
by BrowserUk (Patriarch) on Sep 28, 2009 at 10:11 UTC | |
by ikegami (Patriarch) on Sep 28, 2009 at 14:20 UTC | |
by LanX (Saint) on Sep 28, 2009 at 12:32 UTC |