in reply to Re: Bizarre Results when Creating a Closure
in thread Bizarre Results when Creating a Closure

That produces a reference to a list, not a code ref like the original. Instead of calling $psub->(), you have to write $psub->[0]->($psub->[1]) instead, and that works, but it sure is ugly.

Replies are listed 'Best First'.
Re^3: Bizarre Results when Creating a Closure
by thundergnat (Deacon) on May 04, 2007 at 15:35 UTC

    True, and perhaps I should have been a little clearer...

    The coderef in question is being used as a callback for a PerlTk widget, and a documented way to do closures for widget callbacks is to pass a reference to a list consisting of a coderef an anonymous sub as the first parameter followed by arguments.

    Reference "perldoc Tk::callbacks" or (Google) Tk::callbacks site:cpan.org

    Did you try actually running the code with the modification I proposed? It works exactly as expected.