in reply to Quick Regex Question

Your regex is completely wrong. You say that you want MM/DD/YYYY format, and it will match today's date (05/07/2007) but it excludes, for example, 05/23/2007 (not to mention the fact that it's not Y3K compliant :).

But even if you fixed these problems, how would you deal with eg '02/31/2007' or '39/00/2007'?

One reason why a lot of people love Perl is CPAN, which, among oodles of other stuff, contains a plethora of modules dealing with dates. My personal favourite is Date::Calc, but YMMV.

Here's how I'd use the said module to solve your problem:

use strict; use warnings; use Date::Calc 'check_date'; my $date = '02/31/2007'; # Or whatever my @date = ( split /[-\/]/,$date )[2, 0, 1]; if ( check_date( @date ) ) { # do stuff } else { # print error message }

Simple, n'est-ce pas?

Update: Changed value of $date to avoid possible confusion...