in reply to do'.\dir\file' under -T on Windows

Shouldn't perl -T -e"do'./t\t.pl'" and perl -T -e"do'.\t\t.pl'" do the same thing

Yes. "/" and "\" are equivalent in Windows paths.

I can replicate the problem with ActivePerl 5.6.0, 5.6.1, 5.8.0, 5.8.8, 5.10.0.

Seems the logic for whether @INC should be used or not is broken. Under -T, @INC doesn't contain ".", and do'.\t\t.pl' is using @INC instead of the cd.

(and print 'hi').

Seems so. 5.8.8 on linux:

$ perl -le'@INC=(); do "t/t.pl"' $ perl -le'@INC=(); do "./t/t.pl"' hi $ perl -T -le'@INC=(); do "t/t.pl"' $ perl -T -le'@INC=(); do "./t/t.pl"' hi

Update: Added comparison to linux and explanation of problem.

Replies are listed 'Best First'.
Re^2: do'.\dir\file' under -T on Windows
by Bloodnok (Vicar) on Feb 25, 2009 at 16:19 UTC
    Maybe perl is emulating one of the classic *NIX security fixes (removing the current working directory from the path) in @INC when run in taint checking mode...

    Just a thought ...

    A user level that continues to overstate my experience :-))

      If a taint check for relative paths were to be added, it would throw an exception rather than setting $! to file not found.

      Note that this taint check would be a departure from the current model which allows the current directory to be used.

      $ cat script.pl #!/usr/bin/perl print "unsafe?\n"; $ perl -T -e'$ENV{PATH}=""; system "script.pl";' unsafe?
      $ cat Mod.pm print "unsafe?\n"; 1; $ perl -T -e'@INC = "."; require Mod;' unsafe?

      Sounds like a pretty good idea to me, though. It would break stuff, but nothing that can't be fixed.

        Thanks a lot,

        I sent a description/testcase to perlbug@perl.org .

        Regards, Christoph

      That's fine. The problem isn't that "." isn't present in @INC, it's that @INC is used at all.

      The documented behaviour is to use @INC, but that's clearly not what other systems do when the path can't be a module path, or even on Windows when "/" is used as the separator. I'm not sure how "looks like a module path" is defined, but it's obviously buggy.