in reply to Re^5: error for undefined function that's been imported
in thread error for undefined function that's been imported
There's a lot going on here, so I want to pick things apart to understand the mechanics. First, your code has:
First, why would you have two package statements in a file? that is, I know you can, but I don't see how that alludes to the situation I described (because I'm not doing that). Are you saying that your example illustrates effectively what happens when you use multiple use statements that call other packages into the current file, which is also a package? Is that effectively what I'm doing when I'm doing this:package Hunting::Snark; use Bellman qw(foo bar); # Bellman's exported symbols go into namespace Hunting::Snark # hence &Hunting::Snark::foo is aliased to &Bellman::foo package Boojum; foo(); # is an undefined subroutine. There is no &Boojum::foo
package Hunting::Snark; use Bellman qw(foo bar); use Boojum qw(baz etc); foo(); # is an undefined subroutine. There is no &Boojum::foo
If this is the case, I don't see how any of my code should be working, because (as my first example illustrated), I'm importing packages all over the place, and each of them imports each other. Could it all have been just dumb luck that I haven't started running into this problem more? As my modules are growing, I'm finding this is popping up more frequently.
What I assumed--and what I'd like to eventually get to--is a way to just have each of my packages have their own uniquely defined functions, export them, and have anyone that uses them simply call them by name without having to clutter up the code with Package::func()-style cruft.
Now, since that's how I've been operating, and it seems that's not going to be possible (which I'll accept), what's the next best thing? what sort of coding styles might I adopt to alleviate this problem and still have my code look elegant and easy to read/edit by others?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: error for undefined function that's been imported
by rinceWind (Monsignor) on Aug 16, 2005 at 20:24 UTC | |
by argv (Pilgrim) on Aug 17, 2005 at 07:24 UTC |