N
neurocline
I'm struggling with something. If I have a module, but the package
namespace inside the module doesn't match the path passed to use, then
import (with @EXPORT or @EXPORT_OK) doesn't work. There's something I
don't understand, obviously, but I don't know where the fault is.
If I do
use Extra::Bits::Name qw(func);
and my package is just in "package Name", then I get "Undefined
subroutine &main::fucn" when I try to access just "func" ("Name::func"
works fine). But if I rearranged paths so I can do "use Name
qw(func)", then everything works.
For example, I have a package contained in goober.pm that looks like
this
package goober;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(gooberme);
our $VERSION = '1.00';
sub gooberme
{
print STDERR "yeppers\n";
}
and I have a main program that looks like this
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../CorePerl";
use Blizzard::goober qw(gooberme);
gooberme();
then I get "Undefined subroutine &main::gooberme called at ...".
There's a reason why I can't just completely rearrange my library
paths to make the includes come out matching the package names. Or
rather - I can do that, it will be painful, and I didn't think it
would be necessary.
What am I missing? Obviously I don't understand something about use/
require and how package namespaces work.
namespace inside the module doesn't match the path passed to use, then
import (with @EXPORT or @EXPORT_OK) doesn't work. There's something I
don't understand, obviously, but I don't know where the fault is.
If I do
use Extra::Bits::Name qw(func);
and my package is just in "package Name", then I get "Undefined
subroutine &main::fucn" when I try to access just "func" ("Name::func"
works fine). But if I rearranged paths so I can do "use Name
qw(func)", then everything works.
For example, I have a package contained in goober.pm that looks like
this
package goober;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(gooberme);
our $VERSION = '1.00';
sub gooberme
{
print STDERR "yeppers\n";
}
and I have a main program that looks like this
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../CorePerl";
use Blizzard::goober qw(gooberme);
gooberme();
then I get "Undefined subroutine &main::gooberme called at ...".
There's a reason why I can't just completely rearrange my library
paths to make the includes come out matching the package names. Or
rather - I can do that, it will be painful, and I didn't think it
would be necessary.
What am I missing? Obviously I don't understand something about use/
require and how package namespaces work.