Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

using newer modules

by chorg (Monk)
on Apr 23, 2001 at 20:38 UTC ( #74760=perlquestion: print w/replies, xml ) Need Help??
chorg has asked for the wisdom of the Perl Monks concerning the following question:

I have a user defined modules directory.

I'm not root on the box

I want the latest to use for this

I don't want to break existing scripts

I definitely want to be able to say that I did not break existing scripts.

So I installed into this user defined directory. I use lib "/mydir" like normal, and I note that the code is using the old (root installed) version.

How can I make my code use the updated module? I know it should, but it does not seem to....
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: using newer modules
by suaveant (Parson) on Apr 23, 2001 at 20:42 UTC
    The new dir has to be in your @INC array before the directory of the old

    use #!/usr/bin/perl -I/home/user/mydir

    or use lib '/home/user/mydir';

    before your use CGI and that "should" do it. Weird if it isn't... do you do the use lib after the use CGI?

    Update the good doctor is also very right, if you don't have the path right perl will just ignore it.
                    - Ant

      Ghaaa! A Grievous Error!! I was using the debugger to check what was happening, but did not use the -I switch that was in the shebang line of my program...

      *sigh* Thanks for the help monks - all is well...
      "Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

        Heehee... find me a perl programmer who hasn't made a silly mistake or 20, and I'll show you the biggest liar in the world.
                        - Ant
Re: using newer modules
by Masem (Monsignor) on Apr 23, 2001 at 20:42 UTC
    Assuming that you are using "/mydir", that refers to the top level directory "/mydir" and not to what is in your home account. You probably want something along the lines of "/home/users/myaccountname/myperlstuff" or "~/myperlstuff" to be brief.
    Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain
Re: using newer modules
by TGI (Parson) on Apr 23, 2001 at 20:51 UTC
Re: using newer modules
by AgentM (Curate) on Apr 23, 2001 at 20:45 UTC
    Correct me if I'm wrong but Perl will use the first module it finds (for a match) in @INC. When you use lib;, the directory is pushed onto the array @INC, so when it comes time to search for the module, the old CGI is found first. You'll want to use unshift to add the directory to @INC.

    Update: I was wrong.

    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
      No, Camel book says use lib is almost the same as
      BEGIN { unshift @INC, LIST; }
      except it supports platform specific stuff... so it should work.
                      - Ant

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://74760]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-10-23 04:02 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (125 votes). Check out past polls.