I program in Perl as part of my (Unix Admin) job. It can be fun to be clever and terse in Perl, but for me, it's more important that the code be simple and clear.

As a rule of thumb, I don't use awk when cut will do. I don't use perl when a shell script will do. I don't use modules when a built-in will do.

Of course some modules are essential and it's bad to reinvent the wheel.

My meditation has to do with the maintainability of Perl code that requires modules. I can be reasonably sure people have a relatively recent version of perl, but I'm less sure about modules. At my site, we work very hard to have a consistant environment, but there's more to do. Some people have some pretty bare-bones environments.

As a solution, I'm considering including the modules I need themselves in my code - in other words, my code would be one big program, with the modules themselves embedded. This way, I don't have to worry about someone's include path. Also, the program would be monolithic - non-technical people won't need to worry about maintaining their environments.

Is anyone doing this? Is this is bad idea? It makes your code bigger. Are there other disadvantages that make it not worth it?

Ken Beer

In reply to Prepending Modules to your code by kbeer

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.