juliosergio has asked for the wisdom of the Perl Monks concerning the following question:
Is there in Perl any function to determine if the contents of a string is numeric?
Something that behaves like:
#! /usr/bin/perl # mytest.pl $s = shift; if (isnumber $s) { print "$s is a number\n"; } else { print "$s isn't a number\n"; }
Then when you call it:
./mytest.pl 123.2 123.2 is a number ./mytest.pl aBcd aBcd isn't a number
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: A function to determine if a string is numeric
by toolic (Bishop) on Feb 24, 2012 at 00:46 UTC | |
by juliosergio (Sexton) on Feb 24, 2012 at 00:56 UTC | |
Re: A function to determine if a string is numeric
by ww (Archbishop) on Feb 24, 2012 at 02:28 UTC | |
by jwkrahn (Abbot) on Feb 24, 2012 at 03:39 UTC | |
Re: A function to determine if a string is numeric
by trwww (Priest) on Feb 25, 2012 at 06:51 UTC | |
by zborsos (Initiate) on May 18, 2020 at 11:28 UTC | |
by Tux (Canon) on May 18, 2020 at 12:17 UTC | |
by hippo (Bishop) on May 18, 2020 at 12:19 UTC |
Back to
Seekers of Perl Wisdom