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

comment on

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

I have 2 general rules of thumb.

First: If I need to use a bit of code in more than 1 place, I take that time, instead of a cut/paste, to make it into a sub and change the existing bit of code to call the sub and the new bit of code becomes a call to the same sub.

There are times when the sub needs to be made a bit more generalized and I handle this at that time also.

Second: If I want to use that sub in another script I build that sub into a module which I can then import the function.

At the same time, if it makes sense I try to make the sub into an OO type of interface so I don't need to import the functions into my scripts unless it really makes sense to do it that way.

My experience is that if this overhead is done when there is only 1 existing piece of code which requires changing to use the new interface (sub {} or use Module;) then it is quick and easy to have these nice interfaces so that next time I want this functionality I just type use Module; my $thing=Module->new(...);, or use Module qw( my_keen_sub );

This has a really low cost in the short term and a huge win in the medium to long term, especially if I add a bit of pod to the sub and then a bit more when it gets into a module.


In reply to Re: Perl Module Useage by dga
in thread Perl Module Useage by gawatkins

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 lurking in the Monastery: (6)
As of 2024-03-28 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found