home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / perl / 6930 < prev    next >
Encoding:
Text File  |  1992-11-10  |  2.0 KB  |  51 lines

  1. Newsgroups: comp.lang.perl
  2. 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
  3. From: jgd@acl.lanl.gov (Jerry G. DeLapp)
  4. Subject: Re: Executing required files
  5. In-Reply-To: mjeffery@reed.edu's message of 5 Nov 92 06:21:31 GMT
  6. Message-ID: <JGD.92Nov10153029@kodiak.acl.lanl.gov>
  7. Sender: news@newshost.lanl.gov
  8. Reply-To: jgd@acl.lanl.gov
  9. Organization: Advanced Computing Lab, LANL, NM
  10. References: <JGD.92Oct21135439@kodiak.acl.lanl.gov> <1992Nov05.052448.29379@spillman.uucp>
  11.     <1992Nov5.062131.17033@reed.edu>
  12. Distribution: comp.lang.perl
  13. Date: Tue, 10 Nov 1992 22:30:29 GMT
  14. Lines: 35
  15.  
  16. >>>>> Regarding Executing required files; mjeffery@reed.edu (Mark Jefferys) adds:
  17.  
  18. Mark> In article <1992Nov05.052448.29379@spillman.uucp> tye@spillman.uucp (E. Tye McQueen) writes:
  19. Mark> % jgd@acl.lanl.gov (Jerry G. DeLapp) writes:
  20. Mark> % )[...] Is there a reliable way of determining whether a
  21. Mark> % )program *is being* required or *is being* directly executed?
  22.  
  23. About $^R Mark says:
  24.  
  25. Mark> A bit redundant, since __FILE__ does most of this already.  I'd like:
  26.  
  27. Mark>     __REQUIRED__  Expands to true if file is currently being required.
  28. Mark>     __INCLUDED__  Expands to true if file is currently being included
  29. Mark>                    by "do" or "require".
  30.  
  31. Mark> In the meantime, something like:
  32.  
  33. Mark>     if (__FILE__ eq $0) {
  34. Mark>         # I'm being run directly.
  35. Mark>     } else {
  36. Mark>         # I'm being run by require, eval, or do,
  37. Mark>         # or some idiot set $0.
  38. Mark>     }
  39.  
  40. Very nice, I've just completed my first version using this technique, and it
  41. works just fine. I really like the comment too!
  42.  
  43. I still like the idea of __REQUIRED__ to armor plate me from idiots setting $0
  44. though. Any chance of this appearing in 5.0?
  45.  
  46. Thanks for the suggestion.
  47. --
  48.  
  49. Jerry G. DeLapp -- ACL System Scientist -- (505) 665-4531 <jgd@lanl.gov>
  50. Computing beyond the Bleeding Edge -- The Advanced Computing Laboratory
  51.