in reply to How to check Inputs if Numeric
#!/usr/bin/perl -l use strict; my @inputs = ( qw[1 2 878787 777s7 3.4 3,4 77 abcdef ABCSDEF :: איט !! +!?]); foreach (@inputs) { if ( m/[^0-9.]/ ) {print "$_ \tis not numeric";} else {print "$_ \tis numeric";} } __OUTPUT__ 1 is numeric 2 is numeric 878787 is numeric 777s7 is not numeric 3.4 is numeric 3,4 is not numeric 77 is numeric abcdef is not numeric ABCSDEF is not numeric :: is not numeric איט is not numeric !!!? is not numeric __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to check Inputs if Numeric
by davis (Vicar) on Mar 31, 2004 at 14:52 UTC | |
by pelagic (Priest) on Apr 01, 2004 at 08:18 UTC |