Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Regex Dollar Amounts

by Additude (Initiate)
on Oct 19, 2001 at 15:13 UTC ( [id://119940]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex Dollar Amounts
in thread Regex Dollar Amounts

Hi
Thanks for the help!
I messed up copying my code. Darn.
Here it is again, done correctly.

$Amount =~ /-?(\d+)\.?(\d+)/; $intergerpart = $1; $decimalpart = $2; $lengthdecimal = length($decimalpart); if ($lengthdecimal gt 2 || $Amount =~ /[^0-9]\.?[^0-9]/) { display_output($templatefile,); print <<EOF;

Thanks for the help. I'll give your idea a try.

Replies are listed 'Best First'.
Re: Re: Re: Regex Dollar Amounts
by Additude (Initiate) on Oct 19, 2001 at 15:51 UTC
    Hi Again Eric
    I tried the line
    if($amount =~ m/^-?(\d+)\.(\d\d)$/)
    But this regex is forcing me to put a non digit character in place for it to be true
    If I use $50.00, c50.00, abcd50.00 and so on it will produce a true result and allow the user to pass.
    So here is what I did and it seems to be working
    if ($Amount !~ m/^-?(\d+)\.(\d\d)$/) { display_output($templatefile,);#error page print <<EOF;#good result, move on

    I had to change the =~ to !~ because it didn't like having
     print <<EOF; before the display_output($templatefile,);
    for some reason.
    But it looks like all is well in Dodge City now. Thanks!
    Wes

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-23 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found