I have a file that contains a bunch of subroutines. These subroutines are used in other files which declare namespaces with package.

This file also contains subroutines that are method calls in these packages. For example:

# the new method is in the file. my $p = $namespace->new; # do_this is also a method in this other file my $p->do_this()
One solution is to make this file a base class. But that only works if I am only making method calls. I am not. I am also calling functions like this:
# function_call is a subroutine in that same file my $text = function_call();
So if I don't make this file a base class, I thought of turning it into a module that exports its subroutines. But I am running into trouble. I think the trouble stems from a number reasons:

1. This file contains methods and functions that work together. For example, the do_this() method may change a scalar value in the function_call() subroutine.

2. This file is shared among separate files that are modules in themselves. So module A uses this file's new subroutine to create an object. And module B also uses this file for the same purpose. And module A then uses module B.

I am at my wit's end and don't know what's the best thing to do. Please help. :)


In reply to Arcitectural considerations with modules by Anonymous Monk

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.