use lib

Matthew J Long matt.long at matthew-long.com
Fri Jun 15 16:17:59 CDT 2001


I think it would help if you could clarify your purpose here, but it occurs
to me that this may do what you're looking for:

BEGIN{

    my $INSTALL_DIR=$ENV{INSTALL_DIR};

    my @dirs = (
                         "$INSTALL_DIR/install",
                         "$INSTALL_DIR/install/sql",
                         "$INSTALL_DIR/install/sql/ORACLE",
                         "$INSTALL_DIR/install/sql/SYBASE",
                         "$INSTALL_DIR/install/sql/INFORMIX"
                        );

    foreach my $dir (@dirs)
    {
        if (-d $dir)
        {
            use lib $dir;
        }
    }

}

I didn't test this, so you'll have to play with it. As far as using @INC as
Tim suggested--in essence that is what you are doing by calling 'use lib'.
>From the Camel book (2 ed. pg 138) ... "If you need to modify this list
[refers to @INC] at run-time, you should use the lib module in order to also
get the machine-dependant library properly loaded."

Good luck!

-Matt

----- Original Message -----
From: "John Hundley" <johnh at fgm.com>
To: "Pikes Peak PM's" <pikes-peak-pm-list at pm.org>
Sent: Friday, June 15, 2001 11:39 AM
Subject: use lib


> Hi,
> Does anyone know how to send an array to use lib?  Here is what I am
trying
> to do: I have a given directory tree containing perl packages but I don't
> know where it will be installed.  Also at the bottom of the tree there are
> directories containing perl packages that may or may not be there at
install
> time.  I will have an environment variable set called INSTALL_DIR that
will
> tell me where I am starting from.  Forgive me I am just learning perl but
> basically here is what I think the code should look like:
>
> $INSTALL_DIR=$ENV{INSTALL_DIR};
> @dirs = ("$INSTALL_DIR/install", "$INSTALL_DIR/install/sql",
> "$INSTALL_DIR/install/sql/ORACLE", "$INSTALL_DIR/install/sql/SYBASE",
> "$INSTALL_DIR/install/sql/INFORMIX");
> @valid_dirs= [];
> foreach $dir (@dirs){
> if (-d $dir){
> push @valid_dirs, $dir;
> }
> }
> use lib @valid_dirs;  #this is not working
>
>
> I have tried every way I can think of to pass the array into lib and
nothing
> works. Any Ideas?
>
> Thanks,
> John Hundley
>




More information about the Pikes-peak-pm mailing list