home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5485 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  2.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
  2. From: lwall@netlabs.com (Larry Wall)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: More #! stuff
  5. Message-ID: <1992Aug25.221932.11112@netlabs.com>
  6. Date: 25 Aug 92 22:19:32 GMT
  7. References: <BtCEuC.1K4@world.std.com> <1992Aug24.185939.19357@netlabs.com> <BtI899.KJ2@world.std.com>
  8. Sender: news@netlabs.com
  9. Distribution: usa
  10. Organization: NetLabs, Inc.
  11. Lines: 64
  12. Nntp-Posting-Host: scalpel.netlabs.com
  13.  
  14. In article <BtI899.KJ2@world.std.com> dsb@world.std.com (David Boyce) writes:
  15. : In article <1992Aug24.185939.19357@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
  16. : >Similar schemes have been proposed, but the difficulty with it (aside
  17. : >from the fact that not all machines have /bin/env) is that a #! line
  18. : >typically allows you only one argument, and you've already used it up
  19. : >specifying perl.  It's like having to use up your three wishes to get
  20. : >the genie out of the bottle.
  21. : >
  22. : >Larry
  23. :     When I write shell code, I always use (and recommend)
  24. : #!/bin/sh
  25. : set -e
  26. :     rather than
  27. : #!/bin/sh -e
  28. :     because if you happened to run the script via "sh script",
  29. : the second way would lose the flag, which could be dangerous in
  30. : the case of -e. Does perl support anything like the
  31. : set command? I can't find it, but I, at least, would
  32. : like to have it for the reason cited above, as well as to
  33. : obviate the second problem you mentioned.
  34.  
  35. Most of the options that make sense to set internally can be set
  36. via the corresponding magical variable, e.g.
  37.  
  38.     $^I = ".bak";
  39.  
  40. is the same as
  41.  
  42.     -i.bak
  43.  
  44. (presuming you set it before you start using <>).
  45.  
  46. Many switches don't make sense once you've started compiling the
  47. script, however.  In particular, -p, -n, and -a.  And yes, you
  48. do lose these if you invoke perl directly.  I suppose I could make
  49. perl pick those up from the #! line anyway...  Hmmm...
  50.  
  51. :     As for not every machine having /bin/env; this is true,
  52. : but I think every *ix machine has env, and most of them in
  53. : /bin. I didn't mean that it's the universal solution; just
  54. : that there are probably many local-area networks in the world that
  55. : can count on /bin/env existing across the board. I mean,
  56. : when the alternative is 
  57. : #!/c/cad1/cad/perl/bin/perl
  58. : as it is in one company that I'm working for, I think using env
  59. : is more portable!
  60.  
  61. Surely.  (Presuming of course, that /c/cad1/cad/perl/bin is in your
  62. PATH.)  But the BSD machines I used to use didn't have /bin/env.  Now,
  63. you may not consider them to be *ix, but it would seem that AT&T still
  64. does...
  65.  
  66. Certainly, it's easy enough to write env in C if you don't have it.
  67. (But, of course, if you have authority to install /bin/env, you can also
  68. ln -s /c/cad1/cad/perl/bin/perl /usr/bin/perl.)
  69.  
  70. Larry
  71.