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

Hello, As a requirement for a school project, taint mode must be enabled. But I find when I do enable taint mode with either -t or -T, subroutines found in the do("core.pl"); no longer work and are undefined. How can I continue to use do("X.pl"); along with taint mode?
  • Comment on do("X.pl"); has no effect with tain mode...?

Replies are listed 'Best First'.
Re: do("X.pl"); has no effect with tain mode...?
by almut (Canon) on Apr 15, 2009 at 00:26 UTC

    Specify the path to the file:

    do("/path/to/X.pl"); # or do("./X.pl");

    In taint mode, the "." directory is removed from the @INC paths (which are being searched when you specify a filename only).

      Okay thanks! I think I tried that but I'll give it another go!
Re: do("X.pl"); has no effect with tain mode...?
by ikegami (Patriarch) on Apr 15, 2009 at 02:29 UTC

    subroutines found in the do("core.pl"); no longer work and are undefined.

    Not so. What actually happened is do returned an error and you ignored it. If you start having a problem, the first thing you should do is check for errors if you aren't already!

    That error is do's inability to find the script, and the reason is the removal of "." from @INC by taint mode.