I would like to accept monetary values like

$234.00
$2678

but not values with letters like

$333.oo

This script below almost works, but I can't get it to catch the $40o.89

Is there a simpler way to do this and catch all the conditions?

TIA

Owen


#!/usr/bin/perl

while (<DATA>){
chomp;
$payment=$_;

unless (($payment =~ /\$[\d,]+\.\d{2}/)
or ($payment =~ /\$[\d,]+/)
and ($payment !~ /\$[\d,]+\.\D{2}/))
{print "$payment seems to be an invalid amount\n";}

}
__DATA__
$122.30
$40o.89
$20
$2222.oo

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to