Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Help me improve this sub with named params!

by BUU (Prior)
on Aug 30, 2003 at 04:13 UTC ( #287872=note: print w/replies, xml ) Need Help??


in reply to Re: Help me improve this sub with named params!
in thread Help me improve this sub with named params!

for a slightly nicer version, what about:
my @valid = qw/foo bar baz/; my %args=(stuff); for(@args{@valid}) { next if not defined; }

Replies are listed 'Best First'.
Re: Re: Re: Help me improve this sub with named params!
by blokhead (Monsignor) on Aug 30, 2003 at 05:36 UTC
    I thought of doing something similar, but on the off chance that foobar( valid_arg => undef ); would be actually allowed I wrote what I did. Your code wouldn't be able to distinguish that call from a call that omitted the valid_arg parameter. Also, you'd have to add slightly more code to get key,value pairs (instead of just iterating over the values as you are now). But yours probably is nicer if we don't need to worry about undef parameter values.

    blokhead

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2021-01-26 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?