in reply to Checking for single digit

Try to use beginning and end of line markers. Something like this should help:

if ($input =~ m/^\d$/) { ... }

or

if ($input =~ m/^[0-9]$/) { ... }

It's a good idea also to chomp your input before comparison.

Leonid Mamtchenkov aka TVSET

Replies are listed 'Best First'.
Re: Re: Checking for single digit
by Anonymous Monk on May 06, 2003 at 01:24 UTC
    Fantastic! Works like a champ. Sad thing is, I should've thought of that. Guess you have to take a step back every now and again. For the record, I am chomping my stuff, but my browser is really lame on this system (Japanese Redhat 8) and while pasting in here, I got some funk that didn't allow me to see what I was copying from the xterm. Retyped in Kate and pasted again, and simply forgot to type in the chomp. :) Again - thanks. That's exactly what I was looking for.