in reply to Re^5: perl install in Fedora 16
in thread perl install in Fedora 16

Removed: tk.x86_64 1:8.5.11-1.fc16 Dependency Removed: gtkwave.x86_64 0:3.3.25-1.fc16 python-imaging-tk.x86_64 0:1.1.7-4.fc16 tix.x86_64 1:8.4.3-6.fc15 tk-devel.x86_64 1:8.5.11-1.fc16 tkinter.x86_64 0:2.7.2-5.2.fc16 Installing: tk x86_64 1:8.5.11-1.fc16 updates 1.4 M Transaction Summary ================================================================================ Install 1 Package Total download size: 1.4 M Installed size: 3.4 M Is this ok y/N: y Downloading Packages: tk-8.5.11-1.fc16.x86_64.rpm | 1.4 MB 00:02 Running Transaction Check Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 1:tk-8.5.11-1.fc16.x86_64 1/1 Installed: tk.x86_64 1:8.5.11-1.fc16 Complete! Still no joy, perl generates the same error as before and the package is in a different directory than the @INC path. From what I have read so far, the @INC path is a hash generated by perl at initial install and is not possible to change. Can this be true?

Replies are listed 'Best First'.
Re^7: perl install in Fedora 16
by Eliya (Vicar) on Feb 20, 2012 at 15:32 UTC
    From what I have read so far, the @INC path is a hash generated by perl at initial install and is not possible to change.

    Sure it can be changed:

    • use lib ...
    • the PERL5LIB environment variable
    • the -I command line option
    • manipulating @INC directly, e.g. BEGIN { unshift @INC, "/path/to/libs" }

    (Also, it's not a hash, but an array.)

      So far none of my efforts have changed the @INC at all. It is as it started. BEGIN { use lib "/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 /usr/share/perl5/vendor_perl/AnyEvent/Imp" }; end; produced 'Done" but no change. #use lib '/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 /usr/share/perl5/vendor_perl/AnyEvent/Imp'; likewis, 'Done' but no change inserting into the script: use lib "/usr/share/perl5/vendor_perl/AnyEvent/Iml"; also does not change the entry.

        Not sure what you're expecting to happen when you say it didn't change.  Are you expecting to manipulate @INC permanently?  That's not how it works.  use lib ... changes @INC only for the lifetime of the script.  Also, use lib doesn't take a space-separated string of directories, but a list of directories, if you need more than one.

        Consider this:

        #!/usr/bin/perl -wl use strict; BEGIN { print for @INC; print "-----" } use lib "/usr/share/perl5/vendor_perl/AnyEvent/Iml", "/foo/bar"; BEGIN { print for @INC; print "-----" } # use here whatever module lives in one of the added paths...
        $ ./955116.pl /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12 /usr/local/lib/site_perl . ----- /usr/share/perl5/vendor_perl/AnyEvent/Iml /foo/bar /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12 /usr/local/lib/site_perl . -----

        As you can see in the second printout of @INC (after the use lib), the two directories have been added.

        ___

        P.S.:  please use <p>...</p> (text paragraph) and <c>...</c> (code) tags to format your posts.

        For example, typing

        <p> inserting into the script: </p> <c> use lib "/usr/share/perl5/vendor_perl/AnyEvent/Iml"; </c> <p> also does not change the entry. </p>

        will render as

        inserting into the script:

        use lib "/usr/share/perl5/vendor_perl/AnyEvent/Iml";

        also does not change the entry.