The idea of a function is normally to return something. In other languages there is a way to notify the user whether or not a function was supposed to be used to return anything (like declaring it void, etc.). There is not anything like this in Perl (that I know of) so my best practice is to almost always write functions to return something, even if that something is only undef. Whatever solution you come up with, I would add it to your coding standards. I added this section and all this help about refactoring because I think the code you have posted probably needs to be rewritten. There are good, safe ways to do that using Perl utilities.
Update: Oops, I forgot to mention that your tests will break if you add new stuff like qq| to be.|. The right approach should be to just call the old functions in the new without appending anything and rerun your tests. They should all pass. Then rewrite your tests to match your next version's changes. You should be using a version control system, so you should be able to easily differentiate versions and tag releases along with associated tests.
Celebrate Intellectual Diversity
-
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.
|