Hi,
> 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
How about
# assume ,xx is really supposed to be .xx
$payment =~ s/,(\d{2})$/.$1/;
# throw out any remaining comma
$payment =~ s/,//g;
# it's got to be a dollar sign followed by a number,
# possibly by a decimal dot and two more digits.
if( $payment =~ m/^(\$\d+(\.\d{2})?)$/ ){
print "$1 seems to be a valid amount\n";
}
HTH,
Thomas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>