Dave Mitchell <[EMAIL PROTECTED]> writes:
> Just thought I'd run the following up the flagpole to see if anyone
> laughs at it....
>
> Closures are useful, powerful things, but they can also be
> dangerous and counter-intuitive, espcially to the uninitiated. For example,
> how many people could say what the following should output,
> with and without $x commented out, and why:
>
> {
> my $x = "bar";
> sub foo {
> # $x # <- uncommenting this line changes the outcome
> return sub {$x};
> }
> }
> print foo()->();
Well, I would expect it to output 'foo' on both occasions, and I'm
more than a little surprised to discover that it doesn't. Looks like a
bug to me.
--
Piers Cawley
www.iterative-software.com