in reply to Silly While Loop Problems

gsus:

Try reading perldoc -f chomp. Many also suggest the use of s/\s+$//; to remove all trailing whitespace.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Silly While Loop Problems
by Anonymous Monk on Sep 30, 2011 at 17:52 UTC

    Thanks guys but chomp didn't solve my problem, the strange thing is that if i put a print "$yn"; in the loop it prints the input just fine.

    Do you wish to continue the installation (Y/N) : y y Invalid option, please enter an Y or N : n n Invalid option, please enter an Y or N : Y Y Invalid option, please enter an Y or N : N N Invalid option, please enter an Y or N :

      Don't do print "$yn";.

      Do print "##$yn##\n"; or similar instead. That lets you see whitespace characters

      If you did chomp, it would look like

      Do you wish to continue the installation (Y/N) : y yInvalid option, please enter an Y or N : n nInvalid option, please enter an Y or N : Y YInvalid option, please enter an Y or N : N NInvalid option, please enter an Y or N :

      You've actually proved blue_cowdawg found one of the problems.

      If you did chomp, it would look like

      Do you wish to continue the installation (Y/N) : y yInvalid option, please enter an Y or N : n nInvalid option, please enter an Y or N : Y YInvalid option, please enter an Y or N : N NInvalid option, please enter an Y or N :

      You've actually proved blue_cowdawg found one of the problems.