in reply to Trouble with flow control

The problem lies here:

if ($answer = "n") { &start(); } elsif($answer = "y") {
= 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.

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
    Silly me. Sorry this is what happens when you spend to long sitting in front a screen. Thanks
    All the Best, Eoin...

    If everything seems to be going well, you obviously don't know what the hell is going on.