Before you go and do that, you should probably hear the reasons why it's sometimes (not always), appropriate to import functions into your namespace, or something similar.

Consider the possibility that down the road, you have issues with MySubPackage in a script, but you still need it for other scripts on the system, so don't want to completely overwrite the module. You create MySubPackage2, which has the same interface as the original MySubPackage, and then you just need to change one line of code in this script:

#use MyPackage::MySubPackage; use MyPackage::MySubPackage2; some_function();

If you use fully qualified calls, then you have to go through the script, and find/replace everything, which might be more time consuming. You may also decide that you want to have some logic in your script that dynamically loads the proper 'some_function()' to be used throughout the script, based on other parameters -- in this situation, you want the lines of code that call the function to not worry about what they're actually calling.

Sometimes, tradeoffs in execution time cuts down on the time and effort to change the code down the road, (is part of the issue with premature optimization, which halley mentioned)


In reply to Re^3: package function calling by jhourcle
in thread package function calling by BarMeister

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.