Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Use method/function signatures with Perl

by radiantmatrix (Parson)
on Dec 06, 2004 at 17:28 UTC ( #412703=note: print w/replies, xml ) Need Help??

in reply to Re^2: Use method/function signatures with Perl
in thread Use method/function signatures with Perl

Aha. I knew someone must have had the same general idea before! Thank you for that link. I only have a tiny gripe with it vs. my ideal verifier, which is that Params::Validate only validates, where as what I wrote above would imply validation and returning of the validated parameters (rolling two operations into one).

I'm certainly not about to reinvent a wheel over something so minor, though. The module you recommended will work nicely. Thanks again!

Update: this is what I get for merely scanning the POD before posting. As xdg points out, Params::Validate does everything I have wished for:

use Params::Validate; sub foobar { my ($foo, $bar) = validate_pos ( @_, {type = SCALAR, regex=>/.+/}, {type = HASH_REF} ); print "Using $foo:\n"; return $foo unless %$bar; for (keys %$bar) { print "$_ => $$bar{$_}\n" } return $$bar{'result'}; }

is equivalent to my earlier code.

require General::Disclaimer;
s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

Replies are listed 'Best First'.
Re^4: Use method/function signatures with Perl
by xdg (Monsignor) on Dec 06, 2004 at 19:52 UTC

    I think if you read the POD closely, you'll see Params::Validate does what you want. E.g. (from the POD,

    my @p = validate( @_, 1, { default => 99 } );

    You can also set a global on_fail callback to die however you want.


    Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412703]
[stevieb]: that way, it's still "hard coded" into the exe at least, despite not being visible via Properties
[Marshall]: I also looked into PerlApp from Active State, but they don't sell their Dev Kit independent of a very expensive ($1,200) per year license anymore.
[Corion]: I would assume that the PE format hasn't changed that much since the days of yore, but it seems that I would be wrong in that assumption
[Marshall]: When I bought my copy 15+ years ago, it was just a couple hundred bucks.
[Marshall]: I looked at MS specs for PE format and I didn't see any changes in last decade, but evidenly that would be wrong.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2016-12-08 18:22 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (144 votes). Check out past polls.