This may be better in Meditations - if you have the power to move it and think it should be moved...go ahead!

I've lost count of how many times I've created a module and got this error...

Radar/API.pm did not return a true value at index.pl line 14.
I know exactly how to solve it - simply ensure that there is a true value, usually 1 as the last line of code in the module.

I suspect that almost everyone who has written more than a couple of modules has forgotten this line and got this error.

So why is it part of Perl?

I've been doing some digging and found that it's not just me that finds it frustrating but I have not found an explanation as to why Perl was created like this. Surely there must be a reason for it...

So it got me thinking...
Is there ever a time when one might read the true value and see what it is - i.e 1, 6 or 10?
Is there ever a time when one might want it to return false? I can't imagine this as it's a vague and drastic error. If for some reason, the module cannot be used on the architecture or in the environment then surely a nicer error would be more appropriate.


In reply to Modules return value by Bod

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.