Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

(jcwren) Re: Reduce Redundant Repetition

by jcwren (Prior)
on Jan 21, 2002 at 21:21 UTC ( #140436=note: print w/replies, xml ) Need Help??


in reply to Reduce Redundant Repetition

How about:

$proto = defined $opt_proto ? $opt_proto : 'tcp'

Personally, though, I'd go for putting all your arguments in a hash, with a reference to the opt_arg value, the variable you want the final result in, and the default value, and use a for loop to rip through them setting them all. Perhaps include a type (numeric, string, flag) and do a little type checking. For instance, if someone passed '123' to the $opt_tcp value, it prolly ain't gonna work...

--Chris

e-mail jcwren

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2019-04-18 21:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (105 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!