| Newsgroups |
perl.cvs.perlfaq |
| Message-ID |
<[email protected]> |
cvsuser 02/03/04 13:30:44
Modified: . perlfaq4.pod
Log:
* How do I determine whether a scalar is a number/whole/integer/float?
added newlines to output for a couple of branches of code since the
other branches had them.
Revision Changes Path
1.17 +3 -3 perlfaq/perlfaq4.pod
Index: perlfaq4.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -r1.16 -r1.17
--- perlfaq4.pod 24 Feb 2002 09:18:57 -0000 1.16
+++ perlfaq4.pod 4 Mar 2002 21:30:43 -0000 1.17
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq4 - Data Manipulation ($Revision: 1.16 $, $Date: 2002/02/24 09:18:57 $)
+perlfaq4 - Data Manipulation ($Revision: 1.17 $, $Date: 2002/03/04 21:30:43 $)
=head1 DESCRIPTION
@@ -1890,9 +1890,9 @@
if (/^-?\d+$/) { print "is an integer\n" }
if (/^[+-]?\d+$/) { print "is a +/- integer\n" }
if (/^-?\d+\.?\d*$/) { print "is a real number\n" }
- if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number" }
+ if (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) { print "is a decimal number\n" }
if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/)
- { print "a C float" }
+ { print "a C float\n" }
If you're on a POSIX system, Perl's supports the C<POSIX::strtod>
function. Its semantics are somewhat cumbersome, so here's a C<getnum>