Do you know where your variables are? | |
PerlMonks |
Re: Multiple Conditional Statementsby Perlbotics (Archbishop) |
on Sep 11, 2013 at 11:19 UTC ( [id://1053466]=note: print w/replies, xml ) | Need Help?? |
You should introduce a test function instead of listing all combinations in the if clause. I read your condition as no duplicates allowed, so this should work:
Perhaps you can also use uniq() from List::MoreUtils? Update: In response to vsespb's comment below - the OP didn't specify if e.g. 05.0 is identical to 5 or not - probably yes, so numification is advised. However, as shown below, sanitizing input or creating a specialised all_different_nums() sub can be done by the OP if necessary. Only the OP knows, what is equal in his/her given context. I.e., floats might need normalisation using sprintf... we don't know (yet). Maybe this one is more robust?
In Section
Seekers of Perl Wisdom
|
|