Looks like you hit the nail on the head as to why you would want to abstract a module to a file: because you can maintain it in one place. One subroutine called from many code points, one module used by many programs, etc... One place to make changes!
They should be pasted into your code. It makes it easy to see what it's doing
If the sub/module is named reasonably and it has a good interface, it's trivial to figure out what the calling code is doing, and will take much less space than a cut-and-paste job. Not everything has to be named "foo" ;) ..
I'd make "snippet" a new function. It would take two arguments:
How is snippet(12345678) easier to understand than a well-thought-out modular interface?
and it eliminates a file operation.
Is checking a remote site for updates any better? It sure seems less safe. I know that you as a snippet server administrator would have the best of intentions, but someone more malicious could spoof the site and send back any snippet. So now you're probably looking at doing cryptographic signatures, etc, before this would be taken seriously. Sounds like a lot to save a file operation.

It sounds like your problem with these small modules is not their size, but perhaps a dumb interface. You actually propose to solve a completely orthogonal problem, that of keeping code up-to-date. This does seem like a good problem to look at. Personally, I'd prefer something that planted itself in @ISA and checked CPAN for module auto-updates (I'm sure there are many tools like this out there already). This would happen behind the scenes of my current use statements, so would be of minimal impact.

To solve your original beef with these small modules, it's fine to tailor them to your own needs. Cut and paste the snippets into your code if they're trivial. Write your own with a better interface. Bug the original author to do it ;)

If I do this, you all must contribute to my snippet library (recommended max length per snippet will be announced), and you all must use it.
Charming.

blokhead


In reply to Re: Auto-updating snippets. by blokhead
in thread Auto-updating snippets. by Wassercrats

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.