perl.beginners
[Top] [All Lists]

Re: Regular expression: How to determine wether entry is a number?

Subject: Re: Regular expression: How to determine wether entry is a number?
From: jwkrahn@xxxxxxx (John W. Krahn)
Date: Tue, 29 Jul 2008 10:03:47 -0700
Newsgroups: perl.beginners


Jan-Henrik wrote:
Dear Group,

I'm new to Perl and I have a simple question:

I ask for the entry of a number vie <STDIN>:

----------------------------------------
#!/usr/bin/perl -w
use strict;

my $foo;
print "Enter number: ";
$foo = <STDIN>;
comp($foo);
----------------------------------------

Now I would like to check wether the user really entered a number and
not letters. What would a check like that look like?

perldoc -q "How do I determine whether a scalar is a number"


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

<Prev in Thread] Current Thread [Next in Thread>