Regards, Roberto#!/usr/bin/perl -wl use strict; my @nums = qw( 0e0 0 +0 -0 1. 0.14 .14 1.24e5 24e5 -24e-5 2.3. 2.3.4 1..2 ); for (@nums) { print "ok: ", $_ if is_a_number($_); } ############### sub is_a_number { ############### my $var = $_[0]; $var =~ s/^\s+//; $var =~ s/\s+$//; if ($var =~ /^([+-]?)(\d+\.|\.\d+|\d+)\d*([Ee]([+-]?\d+))?$/) { return(1) } else { return(0) } }
In reply to Re: Matching floats according to perlfaq4
by rbi
in thread Matching floats according to perlfaq4
by jmcnamara
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |