in reply to Trouble with flow control
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: A missleading sub
by eoin (Monk) on Jun 10, 2003 at 16:58 UTC |