Here is an alternative.
#!/usr/bin/perl -wlT
use strict;
use CGI;
use CGI::ArgChecker;
use Data::Dumper;
my $Q = new CGI;
my $checker = new CGI::ArgChecker;
$checker->register_check('BloT',
sub {
warn "You *really* are a GENIUS!!! @_";
return 1;
});
$checker->error_handler(
sub {
warn "You are a GENIUS!!! @_";
});
my $chuck = $checker->argcheck( $Q,
'a' => [ 'disallow_empty', 'want_int' ],
'b' => [ 'disallow_empty', 'BloT' ],
,);
print Dumper $chuck;
__END__
F:\dev\>perl -T argchk.pl a=Where do all the old erections go? -- Adam
You are a GENIUS!!! a want_int at argchk.pl line 19.
You *really* are a GENIUS!!! SCALAR(0x1bc4610) at argchk.pl line 13.
You are a GENIUS!!! b disallow_empty at argchk.pl line 19.
You are a GENIUS!!! b BloT at argchk.pl line 19.
$VAR1 = {
'ERROR' => 1,
'a' => 'Where',
'b' => undef
};
What can I say, I feel *smart* today `.) (btw, CGI::ArgChecker is a wrapper around String::Checker
-
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>
<u> <ul>
-
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
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|