Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Is it possible to create a sub exclusive to a sub?

by BrowserUk (Patriarch)
on Sep 19, 2004 at 10:28 UTC ( [id://392154]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://392154]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-03-29 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found