Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I have one script, two packages, and a module. Let's call them,,, and

I have alot of code, but I've stripped out as much content as possible in order to make my question simple and non-ambiguous.

Both and are packages in their own right (in fact they are OO packages containing methods), and start with the Package keyword in order to define them as such.
In each package there is just one constructor function which works absolutely fine.

This is where the trouble starts ....
I have which is full of lots of useful functions that we use across our site, and I want it to be accessible from everywhere !
So I've placed use common within,, and

However, when I proceed I get an error like this :
Undefined subroutine &pkga::doit called at line 10.
doit is the function within that I am calling from within the constructor method in - although it could be any method.

It's clear that perl doesnt like to load the same module within each package - most likely related to the symbol table and keeping namespaces clean.

I have discovered a fix - by simply creating another module file as a symbolic link e.g.
ln -s and then
use common_for_pkga; within the package file.

However, this seems like a crude fix, and I feel like my understanding of this entire is unsatisfactory.
I've done alot of google and monks searches but haven't been able to find a deeper exaplanation, FIX, or workaround.

This perl disciple/fan would appeciate any help or pointers.
Thanks in advance. Peter.

In reply to Single module spanning multiple Packages, by prhodes

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (11)
    As of 2018-06-19 16:15 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (114 votes). Check out past polls.