Evening Perl Monks
I have a really simple requirement on a project that i'm working on at home which requires what i believe is a while loop. In it's most simple form, i want to prompt a user running a script to enter either Y or N to continue or abort the script.
Below is what i thought might work, oh and i have this in a subroutine.
sub continue_yn { print "Do you wish to continue the installation (Y/N) : "; $yn=<STDIN>; while (lc($yn) ne "y" || lc($yn) ne "n") { print "Invalid option, please enter an Y or N : "; $yn=<STDIN>; } print "Valid option entered"; }
When my program calls this sub routine, no matter what i enter in for the variable $yn it never tests TRUE in the while loop and just continues to prompt me with my Invalid Option message.
Sorry i should have mentioned that once i've gone through the loop i'll have an if statement to either exit and abort the program or just drop out of the sub routine and continue processing.
Thanks
In reply to Silly While Loop Problems by gsus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |