Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Reduce Redundant Repetitionby ybiC (Prior) |
on Jan 21, 2002 at 21:18 UTC ( [id://140434]=perlquestion: print w/replies, xml ) | Need Help?? |
ybiC has asked for the wisdom of the Perl Monks concerning the following question:
The following chunk facilitates default values for command-line arguments. It works fine, but I suspect there's a less redundant approach than just repeating "if defined($opt_foo){$foo=$opt_foo} else {$foo=def_val}" for seven different values of "foo". I'd use hash keys and values, but there are three unique parameters for each iteration.
Suggestions, o wise brethren and sistren?
cheers, Don striving toward Perl Adept (it's pronounced "why-bick")
Back to
Seekers of Perl Wisdom
|
|