http://www.perlmonks.org?node_id=1044555


in reply to comparison of character

If you enter "Y", then $choice ne "N", so the OR clause is true and the while loop continues. You should have used && instead of ||.

Moreover, you can include the first reading of the input into the loop as well:

print "Do you wish to update (Y/N)?\n"; my $choice = q(); while ('y' ne lc $choice and 'n' ne lc $choice) { chomp($choice = <>); }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ