26
loading...
This website collects cookies to deliver better user experience
#!/usr/bin/perl
use v5.16.0;
use warnings;
say "Hello world";
chmod a+x myscript.pl
./myscript.pl
/usr/bin/perl
may be commonly available, but not always, and may not be the perl
the user prefers.env
to run the perl
that comes first in PATH:#!/usr/bin/env perl
perl
with their dependencies, so their shebang must also point to that perl
. This is handled by a shebang rewrite step in the installation process, but it doesn't work for an env
shebang for historical reasons.perl
, even just perl
:#!perl
perl script/myscript.pl
to run it with your preferred perl
and ignore the shebang. If the script depends on modules in lib/
in the same distribution, it is common to run it during development as perl -Ilib script/myscript.pl
.perl
so that it doesn't suddenly start running with a different perl
from the one it was deployed for, which may not have the script's dependencies installed or may behave subtly differently.perl
that should run it on that machine:#!/usr/bin/perl
#!/opt/perl/bin/perl
#!/home/user/perl5/perlbrew/perls/perl-5.34.0/bin/perl
#!/home/user/.plenv/versions/5.34.0/bin/perl
env
shebangs in many cases, but the two common flags used this way are -w
for warnings and -T
for taint mode. -w
is unnecessary and discouraged; just use warnings;
instead.26