in reply to Re^2: adding library directories relative to $0
in thread adding library directories relative to $0
I think he meant it as a way to avoid something like:
$ mkdir -p TEST/{bin,sl}/lib $ echo -e "package myLib;\nour \$VERSION=1.1;\n" >TEST/sl/lib/myLib.pm $ echo -e "package myLib;\nour \$VERSION=1.7;\n" >TEST/bin/lib/myLib.p +m $ cp printval.pl TEST/bin $ cd TEST/bin $ ./printval.pl myLib version: 1.7 search path: /home/marco/TEST/bin/lib /etc/perl /usr/local/lib/perl/5.10.1 . . . $ cd ../sl $ ln --symbolic ../bin/printval.pl printval $ ./printval myLib version: 1.1 search path: /home/marco/TEST/sl/lib /etc/perl /usr/local/lib/perl/5.10.1 . . . $ cat ../bin/printval.pl #!/usr/bin/perl use strict; use warnings; use File::Basename; use Cwd 'abs_path'; my $f; BEGIN { unshift(@INC, abs_path(dirname($0).'/lib')); } use myLib; print "myLib version: ", $myLib::VERSION, "\n"; print "search path: ", join("\n", @INC[0 .. 2], "\t. . ."), "\n";
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: adding library directories relative to $0
by ikegami (Patriarch) on Feb 23, 2011 at 01:29 UTC | |
by wind (Priest) on Feb 23, 2011 at 18:57 UTC | |
by roboticus (Chancellor) on Feb 23, 2011 at 10:29 UTC |