... I am trying to learn how to create modules and needed something
to work on. ... create a module out of [this
monstrosity] by doing the required changes, test the output
by checking it ...
This seems like a reasonable way to learn about creating modules:
start with a lousy algorithm, create a MyModule.pm that
exports something like is_prime(), create a MyModule.t
for the module to test its correct operation (and which can also
test execution time), then start improving the algorithm to exercise
the process of developing, improving and maintaining the module.
Ok, you've got the lousy algorithm. So where's the module and its
.t script? That seems to me to be the thing to focus on right
now. (There are even some who say that one should write the
.t script before writing the module!) Believe me,
you'll find plenty of ways to improve and extend things once you've
got the algorithm encapsulated in a module along with a .t
script for it, i.e., once the interface is defined and testable.
Interface definition and creation of a testing environment is the
first step. Go for it. But at this stage, why are you worrying about
better algorithms?
Give a man a fish: <%-{-{-{-<
-
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.
|