Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Predefining sub Parameters

by willyyam (Priest)
on Jun 23, 2005 at 13:22 UTC ( #469382=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Predefining sub Parameters
in thread Predefining sub Parameters

It's a good point. Damn Canadians and their logic ;-) I wasn't really trying to validate against type so much as by number, and having the first line of my sub definition be a hint as to its usage. I have the attention span of a hummingbird on crack, and I forget what my subs do and how to call them between uses in the same coding session. I also really like having sane variable names in my functions, and @_[1] is not, in my opinion, sane. Useful, but not sane.


Comment on Re^4: Predefining sub Parameters
Download Code
Replies are listed 'Best First'.
Re^5: Predefining sub Parameters
by diotalevi (Canon) on Jun 24, 2005 at 05:02 UTC

    Validate by number? That's even easier. Seriously, go use Params::Validate when you want to do this sort of thing. Its simple enough for casual use and has enough bells and whistles to do heavy duty things too.

    use Params::Validate 'validate_pos'; sub foo { # Three args are required. my ( $foo, $bar, $baz ) = validate_pos( @_, 1, 1, 1 ); ... }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://469382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2015-07-07 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls