The naming convention for SomeModule.pm test code is SomeModule.t. This is not enforced in any way, but it's what everyone expects. | Well, it's what I expected, anyway. See Update Note 1 below.

Some comments on the is_lousy_prime() function code.

if ( $prime_candidate <= 0 ) { return 0; exit; }
The exit; statement in the code above will never be reached. No code in the function will be executed after the return 0; statement executes. There's another example of this unreachable-code syntax in the foreach loop further on in the function.

exit if $prime_candidate == 1 && return 0;
This is more involved, but essentially the same thing is happening: the exit built-in function will never be executed.

And one more thing: Please, please choose a reasonable indentation style and stick to it!

Update:
Notes:

  1. After reading kcott's reply, I thought to myself "Yeah, I do seem to recall spending many happy hours watching files with exactly that nn_name.t format roll by during countless module installs." WTF?!? I think my confusion stems from my practice of writing test scripts with the naming format I mentioned as part of my personal code development best practices. I then conflated personal and general. Oh, well...


Give a man a fish:  <%-{-{-{-<


In reply to Re^2: Stupidest Prime Number detector ever!! (updated) by AnomalousMonk
in thread Stupidest Prime Number detector ever!! by Anonymous Monk

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.