What should I use for a Perl script's shebang line?

后端 未结 8 1861
北荒
北荒 2020-12-02 22:19

Which of these is better or faster to use as the shebang line for a Perl script?

#! perl

#! perl.exe

#! fullpath/perl(/perl.exe)

#! partialpath/perl(/perl         


        
8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 22:43

    1. As ChristopheD noted, I can confirm from practice (ActivePerl on XP) that the shebang line is not really necessary on Windows.

      A shebang line tells a Unix shell which interpreter to pass the script to.

      On Windows, the program to pass the script to will be determined by associations based on the extension.

    2. On Unix, the third option (full path to perl executable) is best.

      And yes, you can use ".." in theory (shell doesn't care) but you should not really use relative path - you never know what your current working directory when executing a script will be.

提交回复
热议问题