in reply to Unexpcted answer

Following this advice I modified your program with
use strict; use warnings;
extra output was
Argument "Y" isn't numeric in numeric eq (==) at - line 14. Argument "N" isn't numeric in numeric eq (==) at - line 14.
Use eq to commpare strings, == for numbers. See perlintro, perlop.