Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rutgers!orstcs!sapphire!pvo3366 From: pvo3366@sapphire.OCE.ORST.EDU (Paul O'Neill) Newsgroups: alt.sources.d Subject: Re: Cmail - C or perl or whatever Message-ID: <13411@orstcs.CS.ORST.EDU> Date: 28 Oct 89 05:45:08 GMT References: <1125@kl-cs.UUCP> <2473@convex.UUCP> <14810@bfmny0.UU.NET> Sender: usenet@orstcs.CS.ORST.EDU Reply-To: pvo3366@sapphire.OCE.ORST.EDU (Paul O'Neill) Organization: Coastal Imaging Lab, Oregon State University, Corvallis, OR Lines: 44 In article <14810@bfmny0.UU.NET> tneff@bfmny0.UU.NET (Tom Neff) writes: > >And please note that the cute device > > #!/usr/bin/perl [-flags] > >which lets some users run perl scripts directly by name as ziplessly as >if they were standalone executables, DOES NOT WORK everywhere. On my >system, it would be necessary to create companion shell scripts or Korn >shell aliases to invoke any such script. > Perl is so cool. From the man page: -S makes perl use the PATH environment variable to search for the script (unless the name of the script starts with a slash). Typically this is used to emulate #! startup on machines that don't support #!, in the fol- lowing manner: #!/usr/bin/perl eval "exec /usr/bin/perl -S $0 $*" if $running_under_some_shell; The system ignores the first line and feeds the script to /bin/sh, which proceeds to try to execute the perl script as a shell script. The shell executes the second line as a normal shell command, and thus starts up the perl interpreter. On some systems $0 doesn't always contain the full pathname, so the -S tells perl to search for the script if necessary. After perl locates the script, it parses the lines and ignores them because the variable $running_under_some_shell is never true. Tom Christiansen obviously wrote the program to show off the language, not to do the job. Take a hint. You're not out in the cold if your vendor didn't supply it. Scarf it, install it. You and your users will thank you. Paul O'Neill pvo@oce.orst.edu Coastal Imaging Lab OSU--Oceanography Corvallis, OR 97331 503-754-3251