On Thu, Feb 21, 2002 at 02:22:48PM +1030, Daniel Falkenberg wrote:
> Is it possible to get a regex to say ... "hang on I only want numerals
> in my variable.
> if ( $var =! Digits ) {

Your regex is: /^\d+$/ , which means:
- any numeral (\d) 
- at least one time (+) 
- but nothing else in that line (surrounded by ^$)

So your code is:

if ($var!~/^\d+$/) {
  print "You entered letters of the alphabet please try again :)";
} else {
  print "U entered only digits... WELL DONE!";
}

For more information on regular expressions in perl,
have a look at man perlre and perlfaq6.

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to