Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-23 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found