develooper Front page | perl.perl5.porters | Postings from June 2008

Re: PERL5OPT -M processed after command line -M?

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
June 2, 2008 23:00
Subject:
Re: PERL5OPT -M processed after command line -M?
Message ID:
b77c1dce0806022300y7835c6bar2b4183e20447f1a8@mail.gmail.com
2008/6/3 David Golden <xdaveg@gmail.com>:
> I was a little surprised to find that -M switches in PERL5OPT get
> processed after any -M options on the command line.  (Whereas -I
> options in PERL5OPT are processed earlier as expected.)
[...]
> The implication is that one can't (shouldn't) use modules in PERL5OPT
> to manipulate @INC or override how modules are loaded.  Among
> practical applications, that would seem to rule out the CPAN::PERL5INC
> trick to replace $ENV{PERL5LIB} munging with a module loaded from
> PERL5OPT.  (Which was intended to avoid having PERL5LIB clipped by OS
> limitations.)
>
> If this is intentional behavior, then it would be good to document it
> in perlrun.  If it's not intentional, should it be fixed?  Or is
> fixing it likely to break other things?

I think it's intentional, because the traditional behaviour is to have
command-line override environment. That can be interpreted in terms of
precedence. I don't know whether anyone relies on that though.

Note that parts of PERL5OPT take effect _before_ the command-line, for
example -T:

$ cat Foo.pm
package Foo;
print "<${^TAINT}>\n";
$ perl -MFoo -e1
<0>
$ PERL5OPT=-T perl -I. -MFoo -e1
<1>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About