The error is in your assumption of how the code is used. The routine I gave doesn't do any validation at all, it just returns a quoted regex which is used elsewhere in the code to properly untaint incoming data:

# $value set to incoming parameter earlier # $param object initialized earlier my $valex = $param->valex; $value =~ /($valex)/; $param->errors( "Parameter '" . $param->name . "' contained invalid data." ) unless(( defined $1 ) and ( $value eq $1 )); $param->value( $1 );

Just for the heck of it I added another test, passing a parameter called 'bart' with a value of 'foo123abc'. I defined 'bart' as an integer and watched this test pass:

is( $valop->value( 'bart' ), 123, 'foo123abc validated correctly' );

Thanks for the reply, though.

UPDATE: I should note that one of the simplifications I made (not expecting the Spanish Inquisition, as they say) to the code in my original post was changing this line in the module:

$_ = shift || $self->validator;

to:

$_ = shift;

In the module, &valex serves a dual purpose which I didn't think pertinent to the question I was asking.


In reply to Re: Dependencies, or, How Common is Regexp::Common? by legLess
in thread 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.