Is there a `use` equivalent of `-T` (taint) used in shebang?

59 Views Asked by At

In the past I placed the Perl options in the "shebang line", like #!/usr/bin/perl -w, but then I discovered that

  • the options will be ignored when the program is run via perl your_perl_file
  • there is use warnings; that does not have the disadvantage listed above

Unfortunately there does not seem to exist an equivalent like use taint; for -T (taint mode). Specifically when debugging such feature would be useful avoiding messages like

"-T" is on the #! line, it must also be used on the command line at ./server.pl line 1.

Did I miss something, or are there reasons why such does not exist (in Perl 5.18)?

1

There are 1 best solutions below

4
ikegami On

It's too late by then. If you use use, you're searching @INC, and the contents of @INC are controller by -T.

What you could do:

die( "$0 must be run with taint enabled (`-T`).\n" ) if !${^TAINT};