And the winner is 'BEGIN' thanks for the feedback. This code will add a search path based on OS Rev. BEGIN { use POSIX qw(uname); my ($uname_s, $uname_r) = (POSIX::uname())[0,2]; unshift(@INC, "/var/opt/modules/$uname_s/$uname_r" ); } If you wish to follow the rest of this problem I have been asked to take it off this list so I am now posting to beginners@perl.org Thread : DynaLoader and lib problems. The above code works unless your module uses DynaLoader to load a sharred obj. For some reason it isn't searching $dir/$archname/auto as documented in `perldoc lib` Module I am using is Solaris::Kstat Scot On Wed, 2002-05-15 at 09:53, scotrn wrote: > Thanks to those who responded. > > There are a few discussons on the net about this. Apparently the use > statements are processed before ANY other perl code so... > > use lib $path is equal to use lib "NULL". > You cannot use a variable yet because perl has not parsed that bit of > code that defines $path. > > The only way I am able to push a dynamic directory onto the INC array is > by wrapping perl in a shell script setting LD_LIBRARY_PATH or > by adding a bit of ugly code. Still can't seem to get DynaLoader to look > in a different directory so I created a sun4-solaris/auto directory under > each 5.6,5.7 amd 5.8 directory to hold my .so files > > use strict; > use POSIX qw(uname); > my ($uname_s, $uname_r) = (POSIX::uname())[0,2]; > > if (($uname_s eq "SunOS") && ($uname_r eq 5.6)) { > use lib qw(/var/opt/modules/SunOS/5.6); > } elsif (($uname_s eq "SunOS") && ($uname_r eq 5.7)) { > use lib qw(/var/opt/modules/SunOS/5.7); > } elsif (($uname_s eq "SunOS") && ($uname_r eq 5.8)) { > use lib qw(/var/opt/modules/SunOS/5.8); > } else { > die("$0 is only supported on Solaris 2.6, 2.7 & 2.8 \n"); > } > > Scot > > On Tue, 2002-05-14 at 16:06, scotrn wrote: > > Hi; > > > > I was wondering if any of you have tried to dynamicly load > > a module from a directory based on the rev of OS? > > > > In other words.... > > my ($uname_s, $uname_r) = split('\s',`uname -sr`); > > > > use lib "/share/local/modules/$uname_s"."/"."$uname_r"; > > > > This seems to work but modules which use DynaLoader to load shared > > objects it's falling back to the original @INC and not looking in > > my lib path. > > > > Trying to support an NFS share which has multiple versions of compuled > > modules bassed on OS Rev. > > > > Thanks > > Scot _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Tue May 21 16:41:25 2002
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:43 EST