Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: matching USD amounts

by Narveson (Chaplain)
on Aug 31, 2009 at 16:48 UTC ( [id://792408]=note: print w/replies, xml ) Need Help??


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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://792408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-24 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found