#! perl -slw use strict; sub test{ ## create a 'local' sub the first time we're called ## As many as you like each with it's own name *test->{localsub} = sub{ print 'localsub1'; return 12345; } unless exists *test->{localsub}; ## USE IT WRONG!! *test->{lacolsub}(); *tset->{localhost}(); } print test; __END__ P:\test>test Name "main::tset" used only once: possible typo at P:\test\test.pl line 14. Use of uninitialized value in subroutine entry at P:\test\test.pl line 13. Can't use string ("") as a subroutine ref while "strict refs" in use at P:\test\test.pl line 13.