First, I hope you mean that you're dividing your code into separate modules (using package) for a clean distinction among responsibilities. It is fundamental to creating maintainable software that you think critically about what parts of your code naturally belong together, and which ought to be split off into separate namespaces. The approach you're taking now feels easier to you as the author, because you're already familiar with the code. But the person coming along after you will have a terrible time making sense of the codebase.

Second, what you're seeing is the fact that the subroutine is returning the result of the last evaluated expression. Unless it's a number less than 1, undef, or the empty string, you had a success. So, the short answer to your question is that you can say return undef at the close of that sub if you really want it to be silent. However, there are three reasons (at least) that you do not want to do this:

  1. if you don't want that value, don't test for it and don't use it, just let it go.
  2. you may not want to test for the success of that sub, but someone else maintaining your code may wish to do so, and be very perplexed that this sub is returning a value that traditionally indicates failure.
  3. testing for the success of subroutines is a Good Thing, and you should get in the habit.


In reply to Re: Calling sub's: return true by djantzen
in thread Calling sub's: return true by FireBird34

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.