in reply to matching USD amounts
Use the regex engine just to locate the number. To see if the number is between a thousand and a hundred thousand, use the built-in Perl implementation of arithmetic.
while (<>) { chomp; print "$_: "; if (my ($number) = /^\$?(\d[,\d]*)/) { $number =~ s/,//g; print $number < 1000 ? 'too small' : $number > 100_000 ? 'too big' : 'just right'; } else {print 'not a number'} print "!\n"; }
|
|---|