If you have to hard code #!, use #!/usr/bin/env perl
. Why? What you want is for the Perl program to run with the user's preferred Perl. That's going to be the first on in their PATH
. #!perl
doesn't do what I mean, it doesn't search the user's PATH, #!/usr/bin/env perl
is how you pull that off. /usr/bin/env
will always be there on Unix systems.
If the user is using Windows, as others have pointed out, it doesn't matter. Windows doesn't use #! it uses file extension associations. Make sure your program is called foo.pl
or something and it'll work. But include the #! line anyway as some utilities and editors make use of it.
Otherwise, you should ship your program with some sort of installer. Both MakeMaker/Makefile.PL
and Module::Build/Build.PL
will change your #! line to match the perl the user used to install with. They will take care of this problem for you.