Thanks Bob.



-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 29, 2001 8:00 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Validate a date


> -----Original Message-----
> From: Ron Rohrssen [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 8:55 AM
> To: Perl Beginners
> Subject: Validate a date
> 
> 
> I'm looking for some advice on better methods of validating a 
> date from a
> text string.
> 
> Currently, I am using Date::Manip like this: $RptDate = 
> UnixDate($strDate,
> "%m/%d/%y"). If this fails the value of $RptDate will be "". 
> That's okay.
> But, this also has the undesirable effect of dumping this 
> message when empty
> strings are evaluated: "ERROR:  Invalid arguments to ParseDateDelta."

You may want to update your Date::Manip; mine (5.40) doesn't 
seem to raise such an error.

Or, you can wrap the UnixDate() call in an eval block:

   eval { $date = UnixDate($s, '%m/%d/%y') };
   undef $date if $@;   # an error was raised, so date is invalid

see perldoc -f eval

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to