Perl include question
Paul Lussier
p.lussier at comcast.net
Wed Dec 7 10:13:00 EST 2005
Dan Coutu <coutu at snowy-owl.com> writes:
> Piece of cake. You need to use the FindBin module that is included in
> the default Perl distribution. Do this:
>
> #!/usr/bin/perl
> use FindBin qw($Bin);
> use lib "$Bin";
> use myinclude;
>
> This assumes that your module is named myinclude.pm and is in the same
> directory as your perl script.
I was just about to make this same recommendation. We've got hundreds
of thousands of lines of perl code here at work, and this is where I
first discovered the FindBin module. We use it extensively here, and
probably wouldn't be able to do things nearly as easily without it.
Almost every script we write has:
use FindBin;
use lib "/build/perl/lastrun/lib";
use lib "$FindBin::Bin/../../../perl/lib";
use lib $FindBin::Bin;
It's really nice to not have to worry about your modules not being found :)
--
Seeya,
Paul
More information about the gnhlug-discuss
mailing list