The problem lies here:
= is used for assignment. == and eq are used for equality testing of numbers and strings respectively. Also, you will want to make your code case insensitive.if ($answer = "n") { &start(); } elsif($answer = "y") {
The corrected code is:
$answer = lc($answer); if ($answer eq "n") { &start(); } elsif($answer eq "y") {
Another alternative altogether would be to check $answer with a regex.
In reply to Re: A missleading sub
by Mr. Muskrat
in thread Trouble with flow control
by eoin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |