I have often seen (sometimes rude) responses to people asking questions that say, "Just install module XYZ". This may not always be the best option, and I cringe when I see that. Here are my reasons for resorting to other peoples' modules last.
- LEARNING I won't learn anything new if I just reuse code. Like the old Proverb, "Give a man a fish, and feed him for the day. Teach a man to fish, and you feed him for life.".
- PERFECTION I'm a perfectionist, and fear someone else's code may be sloppy or not as fast as it could be. Since I often have most of my code written already, I don't want to spend time combing through something else.
- PURPOSE The code does something similar to what I want, but not exactly. I'd spend just as much time to parse the output as I would to rewrite the bits I need.
- APPEARANCE I don't own any of the boxes I'm trying to do something on. "Installing" a module is a bigger perceived change than to just craft a simple script to use. For some of those boxes, the system owner who gave me temporary access may not like me adding a ton of stuff and may be less willing to share a shell next time. Since this is more often than not my customer, I do what I can to work within their preferences.
- PORTABILITY I like to keep everything in one file so that I can move it to another box that may or may not have the same modules, and who knows what versions. If I share my script with someone, I may forget its dependencies when moving it.
- CPAN ACCESS (And this is a big one) Every system that I use is behind numerous firewalls that all restrict access to everything. To install a Perl Module, I'd have to copy all text from each file, and paste it on the target system via an xterm in a similar file structure. Cumbersome.
- COMPILING Most systems I use don't have compilers. Cannot use Perl Modules that need to be built, which for me has been about half of them that I've tried.
- COMPLEXITY It is counter-intuitive to me to install a Perl module for a one-time script. I don't often write Perl code, as much as I run one-off perl commands. Installing a Perl module in a subdirectory of $HOME, then remembering to "use lib qw(/home/me/lib/)" every time I run a command is a lot more work that it is worth.
- SIZE Requiring lots of Perl modules can eat up memory. You may say memory is cheap, but these are government boxes, again not in my control. We have to run MySQL and Apache for 200+ concurrent users at all times in 2GB of memory. Each PM eats up memory and takes time to load.
- LICENSING If the module is GPL, and I'm delivering this as a finished system under a restricted license, I have to get a review from Legal. Ugh.
- JOB I'm paid to write code, not download modules. If I'm asked to write something but get stuck, it would be cheating if I just downloaded something else. I'm not looking for the answer, I'm looking for a hint.
Off the soapbox and back to work.
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>
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
Want more info? How to link or
or How to display code and escape characters
are good places to start.