Perl include question
Kevin D. Clark
kevin_d_clark at comcast.net
Mon Dec 5 16:30:01 EST 2005
Cole Tuininga writes:
> I have a module (call it MyMod.pm) that I want to use in a program, but
> I can't install it in with the rest of the perl libraries. For reasons
> that are too boring to get into, the only guarantee I have is that it
> will be in the same directory as the executable script.
>
> How can I set up my include path (within the perl script) to make sure
> that the directory of the executable is in the include path? I can't
> hard code it because the location might be different on different
> machines (different mount points).
Try this:
#!/usr/bin/perl
BEGIN {
$dirname = $0;
$dirname =~ s#(.*/).*#$1#;
eval "use lib qw($dirname)";
}
use MyMod;
Hope this helps,
--kevin
--
GnuPG ID: B280F24E
More information about the gnhlug-discuss
mailing list