Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- PERL 4.0 Reference Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

     -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.   A  better  construct  than  $*  would be
          ${1+"$@"}, which handles embedded spaces  and  such  in
          the  filenames, but doesn't work if the script is being
          interpreted by csh.  In order to  start  up  sh  rather
          than  csh, some systems may have to replace the #! line
          with a line containing just a colon, which will be pol-
          itely  ignored  by  perl.   Other systems can't control
          that, and need a totally devious  construct  that  will
          work  under any of csh, sh or perl, such as the follow-
          ing:

               eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
               & eval 'exec /usr/bin/perl -S $0 $argv:q'
                    if 0;

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson