My $client has a lot of locally defined modules that pull in other locally defined modules. Every module contains a literal:
use lib "/our/local/lib";
so that the following "use" calls will work. Well, that's a problem, because even though I can get a CVS view of the tree in /our/local to make changes, I can't "prefer" my local view. Until I did this...
use lib "/our/local/lib"; BEGIN { no strict; # off with the handcuffs, I say no warnings; my $old_lib_import = lib->can("import") or die; *lib::import = sub { my $self = shift; my @args = grep $_ ne "/our/local/lib", @_; if (@args) { # ok, they want something else $self->$old_lib_import(@args); } }; } use lib "/home/merlyn/project/lib"; # now put mine ahead of /our/local +/lib

Replies are listed 'Best First'.
Re: add defang wrapper to "use lib"
by ambrus (Abbot) on May 11, 2005 at 15:29 UTC

    Wouldn't the good solution be just to add the use lib path (and the perl path in the shebang line) only at make install time? If you are developping the program, you can run it from the source tree as wd, and the implicit . in @INC will do its work.

      That would be better, but these other module files aren't installed with Makefile.PL. They're checked into the $client's version control system, and merely extracted in place on the development and production machines. Thus, I wanted to defang those "use lib" that tried to push the production versions of the libs in front of my development versions. And that's what this snippet does, by slightly altering the behavior of "use lib".

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.