Pathologically Eclectic Rubbish Lister | |
PerlMonks |
only allow certain parametersby aufrank (Pilgrim) |
on Aug 09, 2002 at 22:19 UTC ( [id://189073]=perlquestion: print w/replies, xml ) | Need Help?? |
aufrank has asked for the wisdom of the Perl Monks concerning the following question: hey all-- I'm working on a method in my first OO project which seems like it should be simple but ended up pretty complex (and still doesn't DWIW). The idea is that I only want to allow certain values to be passed as parameters, and I want to assign a default if the value passed is not one of the legal ones. Here my attempted WTDI:
initially this seemed to work fine, but when I went back and added the line it still prints "bar". I realize now that the way I used the unless loop makes it impossible to update the value once it has been defined once, but I am at a loss. How should I go about doing this? thanks in advance, this was going to be a question about lists, arrays, $_, @_, and shift, but an excellent CB discussion unmuddied my head a bit (or at least showed me that the subject is inherently muddy ;-)
Back to
Seekers of Perl Wisdom
|
|