D
David Filmer
Greetings.
I want to have my own module directory that is visible to all my Perl
programs without futzing with "use libs" and such in each program (and
I don't want to recompile Perl either). So I decided to put my module
in some version-independent directory in @INC.
So I do
perl -le 'print join "\n", @INC'
and see
...
/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi
...
Hmm. /usr/lib/perl5/site_perl sounds good. So I create a
directory /usr/lib/perl5/site_perl/Filmer and therein place a little
test module named Foo.pm:
package Foo;
BEGIN {
use Exporter ();
our @ISA = qw(Exporter);
our @EXPORT = qw{ &bar };
}
sub bar {
return "Hello World\n";
}
1;
Now I write a little test program to call Filmer::Foo::bar
#!/usr/bin/perl
use Filmer::Foo;
print bar();
And Perl complains:
Undefined subroutine &main::bar called at ./foo.pl
It doesn't matter if I
use Filmer::Foo qw{ bar };
or
print Filmer::Foo::bar();
I know that Perl is checking in the Filmer directory, because if I try
to
use Filmer::Baz; # invalid - there is no Baz.pm
then Perl (rightly) complains
Can't locate Filmer/Baz.pm in...
So why isn't Perl finding bar()?
Any insight is greatly appreciated.
Thanks!
I want to have my own module directory that is visible to all my Perl
programs without futzing with "use libs" and such in each program (and
I don't want to recompile Perl either). So I decided to put my module
in some version-independent directory in @INC.
So I do
perl -le 'print join "\n", @INC'
and see
...
/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi
...
Hmm. /usr/lib/perl5/site_perl sounds good. So I create a
directory /usr/lib/perl5/site_perl/Filmer and therein place a little
test module named Foo.pm:
package Foo;
BEGIN {
use Exporter ();
our @ISA = qw(Exporter);
our @EXPORT = qw{ &bar };
}
sub bar {
return "Hello World\n";
}
1;
Now I write a little test program to call Filmer::Foo::bar
#!/usr/bin/perl
use Filmer::Foo;
print bar();
And Perl complains:
Undefined subroutine &main::bar called at ./foo.pl
It doesn't matter if I
use Filmer::Foo qw{ bar };
or
print Filmer::Foo::bar();
I know that Perl is checking in the Filmer directory, because if I try
to
use Filmer::Baz; # invalid - there is no Baz.pm
then Perl (rightly) complains
Can't locate Filmer/Baz.pm in...
So why isn't Perl finding bar()?
Any insight is greatly appreciated.
Thanks!