Validating price (US Currency)

2001-04-23 Thread David Gilden
Is there a better way of doing this? Thanks! Dave if ($in{'price'} eq "") {print '• Missing '; } elsif (&checkPrice($in{'price'})) { print '• Wrong Format'; } sub checkPrice{ if ($_[0] =~ /\$?(\d*)(\.\d{0,2})?/) { return 1; } else { return 0; } } Allowable input:

Re: Validating price (US Currency)

2001-04-23 Thread Paul Johnson
On Mon, Apr 23, 2001 at 11:38:42AM -0400, David Gilden wrote: > Is there a better way of doing this? Hmmm. Where to start? :-) > Thanks! > Dave > > > > if ($in{'price'} eq "") {print '• Missing '; } > elsif (&checkPrice($in{'price'})) { > print '• Wrong Format'; > } > > > >

Re: Validating price (US Currency)

2001-04-23 Thread Casey West
On Mon, Apr 23, 2001 at 11:38:42AM -0400, David Gilden wrote: : Is there a better way of doing this? Dave, here is my take on it, hopefully commented well: #!/usr/local/bin/perl -w use strict; $|++; while ( ) { chomp; print( &validate( $_ ) ? 'valid entry' : 'try again punk' ); print "\

Re: Validating price (US Currency)

2001-04-23 Thread Paul Johnson
On Mon, Apr 23, 2001 at 01:15:13PM -0400, David Gilden wrote: [ brought back to the list with permission ] > my camel learning perl book has hashs with the key in quotes, > whats going on with this? In the early days this was necessary, otherwise the key would be interpreted as a function and i