home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!reed!mjeffery
- From: mjeffery@reed.edu (Mark Jefferys)
- Newsgroups: comp.lang.perl
- Subject: Re: Executing required files
- Message-ID: <1992Nov5.062131.17033@reed.edu>
- Date: 5 Nov 92 06:21:31 GMT
- Article-I.D.: reed.1992Nov5.062131.17033
- References: <JGD.92Oct21135439@kodiak.acl.lanl.gov> <1992Nov05.052448.29379@spillman.uucp>
- Distribution: comp.lang.perl
- Organization: Reed College, Portland, OR
- Lines: 34
-
- In article <1992Nov05.052448.29379@spillman.uucp> tye@spillman.uucp (E. Tye McQueen) writes:
- % jgd@acl.lanl.gov (Jerry G. DeLapp) writes:
- % )[...] Is there a reliable way of determining whether a
- % )program *is being* required or *is being* directly executed?
-
- % Perhaps an extension:
- %
- % $^R The name of the file currently being included by
- % "do" or "require".
- %
- % would be nice.
-
- A bit redundant, since __FILE__ does most of this already. I'd like:
-
- __REQUIRED__ Expands to true if file is currently being required.
- __INCLUDED__ Expands to true if file is currently being included
- by "do" or "require".
-
-
- In the meantime, something like:
-
- if (__FILE__ eq $0) {
- # I'm being run directly.
- } else {
- # I'm being run by require, eval, or do,
- # or some idiot set $0.
- }
-
- Should work pretty well.
-
-
- Mark
- --
- Mark Jefferys Internet: mjeffery@reed.edu
-