Monks ~

I'm building a module, one of whose jobs is parsing input. It's been pointed out to me that input parsing has been done before :) and I'm looking for a way to be more constructively lazy about it. At the same time, I want to avoid a disease that has plagued me lately: multiple nested dependencies.

Perl folks I know here in Portland dot the spectrum from "Never use dependencies other than what comes with the default install," to "Who cares if it's a 3-year-old .01?" My own position on that scale varies depending on how obscure the dependency is, how much work it saves me, how much value it adds, and other such things. I've seen other discussions of this issue here, so feel free to skip that part of my question if you're bored with it.

Right now the module depends on CGI and nothing else; the module I'm thinking of using is Damian's (now Abigail's) Regexp::Common.

So my questions:

  1. How common is Regexp::Common? Perlmonk's own host doesn't have it installed by default; Red Hat and Debian don't have packages for it. I don't know about other sites. (see NOTE)
  2. I have an urge to roll this myself: am I in a state of sin?

Here's a simplified snip of the code I have now:

sub valex { my $self = shift; $_ = shift; /^integer$/ and return qr/\d+/; /^word$/ and return qr/\w+/; # etc. return undef; }

Using Regexp::Common would replace the qr//s above. The benefits are a richer and more robust set of regexen: Damian and Abigail have wicked Perl-fu. The drawbacks are added complexity and a dependency of perhaps questionable value (for this application: notice I have no heartache using CGI :).

(NOTE) I don't care how easy or difficult it is for me to install dependencies, but one of the design goals is to avoid interface complexity in common situations. I very much want users of the module to be able to specify plain words as validators: 'integer', 'email', etc. So I'd be wrapping the common regexen with the valex sub anyway, and only using Regexp::Common internally. I have confidence (and so far my test suite agrees with me) that I can write or find these myself.

Thanks for your time and replies.


In reply to Dependencies, or, How Common is Regexp::Common? by legLess

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.