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

The only "global variable use", it *main::test, which is in use anyway and has several slots going free. And I guess obfuscated is in the eye of the beholder.


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^4: Is it possible to create a sub exclusive to a sub?
by Aristotle (Chancellor) on Sep 19, 2004 at 10:35 UTC

    You use %main::test. That that's the same as *main::test{HASH} and *main::test{CODE} happens to be defined doesn't make it any less of a global variable. At least if you're going to go that route, do it directly

    use vars qw( %test ); # ... $test{localsub}->();

    so that strict can catch your typos. (Though it still won't catch $test{lcoalsub}, as opposed to a lexical mistyped as $lcoalsub.) The way you wrote it deprives you of protection wholly.

    Makeshifts last the longest.