Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Best CPAN library for named subroutine arguments/parameters

by hermida (Scribe)
on Oct 26, 2011 at 00:45 UTC ( #933761=perlquestion: print w/ replies, xml ) Need Help??
hermida has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone, searching CPAN I cannot find a recently maintained library to support named subroutine arguments/parameters. What CPAN library is recommended?

GetArgs::Long
Params::Smart
Sub::NamedParams

others that I haven't found?

Comment on Best CPAN library for named subroutine arguments/parameters
Re: Best CPAN library for named subroutine arguments/parameters
by Util (Priest) on Oct 26, 2011 at 01:30 UTC
Re: Best CPAN library for named subroutine arguments/parameters
by repellent (Priest) on Oct 26, 2011 at 08:10 UTC
Re: Best CPAN library for named subroutine arguments/parameters
by Arunbear (Parson) on Oct 26, 2011 at 09:39 UTC
      > Smart::Args looks interesting.

      It certainly does, but unfortunately it requires PadWalker. :(

      Cheers Rolf

        What's wrong with PadWalker?
Re: Best CPAN library for named subroutine arguments/parameters
by salva (Monsignor) on Oct 26, 2011 at 10:10 UTC
    The overhead introduced by most of these modules is quite significant as they make several subroutine calls for every argument processed under the hood. That may be admissible or not for your particular case.

    This is my preferred way of handling named parameters:

    sub foo { my ($self, %opts) = @_; my $foo = delete $opts{foo} // 'default_foo'; my $bar = delete $opts{bar} // croak "required parameter bar missing +"; ... %opts and croak_bad_args(\%opts); ... }

    It requires some more coding but is cheap.

Re: Best CPAN library for named subroutine arguments/parameters
by DrHyde (Prior) on Oct 26, 2011 at 12:20 UTC
    Why would you only be interested in stuff that has been updated recently? If it's old, that is more likely to mean "it just works" than "it's been abandoned and is full of bugs".
      That is absolutely true, just wanted to make sure that when I select a certain CPAN library to use and include in my software distribution that it's not obsolete, or not maintained, etc. But you are right if it just works then I shouldn't care so much :-)
Reaped: Re: Best CPAN library for named subroutine arguments/parameters
by NodeReaper (Curate) on Oct 26, 2011 at 12:52 UTC
Reaped: Re: Best CPAN library for named subroutine arguments/parameters
by NodeReaper (Curate) on Oct 29, 2011 at 12:59 UTC
Reaped: Re: Best CPAN library for named subroutine arguments/parameters
by NodeReaper (Curate) on Oct 30, 2011 at 13:17 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://933761]
Approved by ww
Front-paged by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-08-20 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (113 votes), past polls