There's a lot going on here, so I want to pick things apart to understand the mechanics. First, your code has:

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

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); 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?


In reply to Re^6: error for undefined function that's been imported by argv
in thread error for undefined function that's been imported by argv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.