home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!convex!darwin.sura.net!jhunix.hcf.jhu.edu!aplcen.apl.jhu.edu!saimiri.primate.wisc.edu!sdd.hp.com!caen!hellgate.utah.edu!lanl!newshost.lanl.gov!jgd
- From: jgd@acl.lanl.gov (Jerry G. DeLapp)
- Subject: Re: Executing required files
- In-Reply-To: mjeffery@reed.edu's message of 5 Nov 92 06:21:31 GMT
- Message-ID: <JGD.92Nov10153029@kodiak.acl.lanl.gov>
- Sender: news@newshost.lanl.gov
- Reply-To: jgd@acl.lanl.gov
- Organization: Advanced Computing Lab, LANL, NM
- References: <JGD.92Oct21135439@kodiak.acl.lanl.gov> <1992Nov05.052448.29379@spillman.uucp>
- <1992Nov5.062131.17033@reed.edu>
- Distribution: comp.lang.perl
- Date: Tue, 10 Nov 1992 22:30:29 GMT
- Lines: 35
-
- >>>>> Regarding Executing required files; mjeffery@reed.edu (Mark Jefferys) adds:
-
- Mark> In article <1992Nov05.052448.29379@spillman.uucp> tye@spillman.uucp (E. Tye McQueen) writes:
- Mark> % jgd@acl.lanl.gov (Jerry G. DeLapp) writes:
- Mark> % )[...] Is there a reliable way of determining whether a
- Mark> % )program *is being* required or *is being* directly executed?
-
- About $^R Mark says:
-
- Mark> A bit redundant, since __FILE__ does most of this already. I'd like:
-
- Mark> __REQUIRED__ Expands to true if file is currently being required.
- Mark> __INCLUDED__ Expands to true if file is currently being included
- Mark> by "do" or "require".
-
- Mark> In the meantime, something like:
-
- Mark> if (__FILE__ eq $0) {
- Mark> # I'm being run directly.
- Mark> } else {
- Mark> # I'm being run by require, eval, or do,
- Mark> # or some idiot set $0.
- Mark> }
-
- Very nice, I've just completed my first version using this technique, and it
- works just fine. I really like the comment too!
-
- I still like the idea of __REQUIRED__ to armor plate me from idiots setting $0
- though. Any chance of this appearing in 5.0?
-
- Thanks for the suggestion.
- --
-
- Jerry G. DeLapp -- ACL System Scientist -- (505) 665-4531 <jgd@lanl.gov>
- Computing beyond the Bleeding Edge -- The Advanced Computing Laboratory
-