in reply to Re^8: Is it possible to create a sub exclusive to a sub?
in thread Is it possible to create a sub exclusive to a sub?

Also, that doesn't work.

#! perl -l use strict; use warnings; sub test{ our $test{localsub} = sub{ print 'localsub1'; return 12345; } unless exists $test{localsub}; $test{localsub}->(); } print test; __END__ P:\test>junk syntax error at P:\test\junk.pl line 6, near "$test{localsub" Execution of P:\test\junk.pl aborted due to compilation errors.

It would have to become:

#! perl -l use strict; use warnings; sub test{ our %test; $test{localsub} = sub{ print 'localsub1'; return 12345; } unless exists $test{localsub}; $test{localsub}->(); } print test;

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^10: Is it possible to create a sub exclusive to a sub?
by Aristotle (Chancellor) on Sep 19, 2004 at 11:54 UTC

    Err, yes. I wrote that code in the browser, then pasted into a file to test, then corrected it in the file the way you did, but then failed to paste it back to the browser. D'oh.

    Makeshifts last the longest.