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

I have taint mode in use via the #! as the following: #!/usr/local/bin/perl -T -w -i ~me/mypath/ My Problem: I cannot figure out why I'm unable to locate a library I have created in the included directory (~me/mypath) as seen above and also verified to be included inside of(@inc) via the error message:
Can't Locate mypackage.pm in @INC (@INC contains: (bunch of packages). +.. ~me/mypath) at myfile.pl line 12.
Now here is the catch... if I remove -T... it works? Now I know that something has to do with me making my own package, but how can this be effected by the -T option? How can it also say it can find my package in the directory it says it has in @inc... it just doesn't make clear sence. Help would be good... Thanks Gunder

Replies are listed 'Best First'.
Re: Taint mode
by jasonk (Parson) on Apr 07, 2003 at 14:11 UTC

    Well, I just tried it out with 5.8.0 and 5.6.1, and -T wasn't the problem. It worked for me with or without -T. The problems that I see in your code are first, that -i doesn't affect @INC at all, but since you say that directory appears in the error message, I'm assuming you actually have -I. And second, perl doesn't understand ~me, you need to put a fully-qualified path there.


    We're not surrounded, we're in a target-rich environment!
      Well it appears that the path was the problem... thanks. So note to myself, must use fully-qualified paths...
Re: Taint mode
by davorg (Chancellor) on Apr 07, 2003 at 14:23 UTC

    As jasonk points out, -i doesn't have any effect on the contents of @INC, you may want -I instead.

    However, -T, does have an effect on @INC - it removes the current directory from it. If you're running your program from ~me/mypath then that could well explain the behaviour you're seeing.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Except perl doesn't understand the ~username syntax, so a path starting with ~username will never be the current path, because perl won't expand the tilde. (And I've never heard this before, perlsec doesn't say anything that I can see about taint mode removing the current directory from @INC, and a quick test with 5.8.0 and 5.6.1 doesn't show this behavior.)


      We're not surrounded, we're in a target-rich environment!
        Except perl doesn't understand the ~username syntax, so a path starting with ~username will never be the current path, because perl won't expand the tilde.

        Good point. It works on the command line tho' as that's expanded by the shell.

        (And I've never heard this before, perlsec doesn't say anything that I can see about taint mode removing the current directory from @INC, and a quick test with 5.8.0 and 5.6.1 doesn't show this behavior.)

        Strange. It works here with both 5.6.0 and 5.6.1. Don't know why it isn't in perlsec tho'.

        $ perl -le 'print "@INC"' /usr/lib/perl5/5.6.0/i586-linux /usr/lib/perl5/5.6.0 /usr/lib/perl5/si +te_perl/5.6.0/i586-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl +5/site_perl . $ perl -Tle 'print "@INC"' /usr/lib/perl5/5.6.0/i586-linux /usr/lib/perl5/5.6.0 /usr/lib/perl5/si +te_perl/5.6.0/i586-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl +5/site_perl

        Notice the '.' which is missing from the end of the second version.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg