princepawn has asked for the wisdom of the Perl Monks concerning the following question:

I don't want each of my CGI scripts to have
#!/usr/bin/perl -wT
at the top.

I want this automatically done somehow. How can I do this?

Replies are listed 'Best First'.
Re: automatically choosing perl executable for CGI scripts
by dws (Chancellor) on Nov 12, 2001 at 06:24 UTC
    I don't want each of my CGI scripts to have #!/usr/bin/perl -wT at the top. I want this automatically done somehow. How can I do this?

    I'm not clear on which of several problems you're trying to solve, so I'll assume that you don't want to hard-code the path in scripts that you intend to distribute, where they might break if they're installed on a box where Perl lives somewhere else.

    The common way I see people addressing this is by writing an install script that first finds (or guesses, or asks for) the path to Perl, and then fixes up the #! line on each executable script component.

    A alternate trick from the path-less-traveled is to use   #!./perl -wT then make a symbolic link the proper perl executable. This doesn't work for CGIs on Win32, but then neither does -T in the #! line. Some will consider this approach less than wise.

      This doesn't work for CGIs on Win32, but then neither does -T in the #! line.

      Actually -T works perfectly fine on Windows with Apache. As I discovered with IIS you have to hard code it else where.... Taint with Perl on NT/IIS.

      On Windows if you run IIS then the shebang is ignored, so you don't need it, and Apache can either follow the shebang (default) or use the Registry like IIS does.

Re: automatically choosing perl executable for CGI scripts
by Asim (Hermit) on Nov 12, 2001 at 08:36 UTC

    Possibly the easiest way to to use the PERL5OPT Environmental Variable, as described in perlrun:

    PERL5OPT Command-line options (switches). Switches in this variable are taken as if they were on every Perl command line. Only the -DIMUdmw switches are allowed. When running taint checks (because the program was running setuid or setgid, or the -T switch was used), this variable is ignored. If PERL5OPT begins with -T, tainting will be enabled, and any subsequent options ignored.

    ----Asim, known to some as Woodrow.

Re: automatically choosing perl executable for CGI scripts
by perrin (Chancellor) on Nov 12, 2001 at 21:23 UTC
    The beginning of the perlrun man page has some information on getting the shell to find perl for you.