in reply to Re: classifying data
in thread classifying data
This could help you get started:
use warnings; use strict; while (<DATA>) { chomp; my $data = $_; print "$data: "; my $result = ($data =~ /^[+\-]?\$?[0-9.]+$/) ? "numeric" : "non-numeric"; print "$result\n"; } __DATA__ 1020 $10.21 -1023 +1.024 beer 10$25 -$102.6 A1027 1028$ $ $-1.029
BTW, watch out for those asterisk opertors in your patters. You used \d*, and the '*' could legitimately match '', since it does match a digit zero or more times! That pesky asterisk operator can lead to 'zero-width' matches, which can drive you nuts when you are starting with regular expresssions.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: classifying data
by Abigail-II (Bishop) on Jan 19, 2004 at 16:50 UTC | |
by Art_XIV (Hermit) on Jan 19, 2004 at 17:40 UTC |