|
|
| go ahead... be a heretic | |
| PerlMonks |
Re: Silly While Loop Problemsby TomDLux (Vicar) |
| on Sep 30, 2011 at 18:24 UTC ( #928890=note: print w/ replies, xml ) | Need Help?? |
|
If the input were 'y', the first part of the || would be false, but the second part would be true. For an input of 'n', the first part is true while the second is false. Any other input, both parts are true. The only way to avoid the loop if the input is simultaeneously 'y' and 'n'. Only Damian can do that. I would use shortcut returns to drastically simplify the condition:
Or use a hash to specify the set of valid inputs.
WARNING: not tested. Provided for concepts, not cut-and-paste. As Occam said: Entia non sunt multiplicanda praeter necessitatem.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||