Shlomi Fish wrote: > On Saturday 26 Sep 2009 03:18:35 Steve Bertrand wrote:
>> I'm concerned about how I slurp in my params. For some reason, it >> 'feels' very dangerous to me. >> >> Can someone recommend the reading I need to do to ensure that I've been >> over the possible ramifications? IOW, I'd like to spend more time >> learning about the type of params one should use, when they should be >> used, and when certain param types MUST be used (irt standard types, and >> refs). > A few notes. > >> sub captcha { >> >> my $self = shift; >> my %params = @_; >> > > My personal preference is to do something like: > > {{{ > my $params = shift; > }}} > > And pass it as a > > <<<<<<<< > $self->my_method( > { > %hash, > } > ) > > This way it is faster and more robust than clobbering the hash into @_. I gotcha. If I want someone to use one of my function calls that takes a single href as a param, would it be fair to say that my understanding is becoming stronger by thinking that my documentation must be specifically accurate and easy to understand? iow, if my documentation is not accurate, then I am responsible for breakage when incorrect params are passed in. Otherwise, if my doc is correct (and understandable), then the "you're on your own" rule applies...yes? >> >> my $captcha = $params{ -captcha }; >> my $input = $params{ -input }; > > You shouldn't use a leading "-" for the parameter keys. Just do: > > <<<<<<<< > my $captcha = $params{captcha}; > my $input = $params{input}; > > "-" is a remnant from the olden days. Je comprends. > Now to answer your question - you may wish to look at Params::Validate and > similar modules: > > http://search.cpan.org/dist/Params-Validate/ I most certainly will. Thanks Shlomi, Steve
smime.p7s
Description: S/MIME Cryptographic Signature