in reply to die on carriage return

The problem is probably located a few lines earlier. You could chomp $number before performing the tests. Then check for an empty input, e.g. like:

die "Enter is not valid" unless length $number;

Replies are listed 'Best First'.
Re^2: die on carriage return
by cdarke (Prior) on Dec 31, 2008 at 11:25 UTC
    Or even:
    die "Enter is not valid" unless $number;
    Since an empty string is false.

    Update: Thanks to Perlbotics for pointing that this would mark 0 as invalid. Doh!
      I thought zero was a number.
      Hello Thanks that works quite well now, quite simple really :)