Here is a date chcking routine for you. It will allow 1 or 2 digit entries for day and month to avoid leading 0 requirement. If you want to insist on two digits remove the question marks.
$date = "2000-12-1"; unless ($date =~ m/(\d\d\d\d)-(\d\d?)-(\d\d?)/) { die "Invalid date format\n"; } # put captured data from regex into appropriate vars my ($year,$month,$day) = ($1,$2,$3); die "Invalid year!" if $year < 1900 or $year > 2100; die "Invalid month!" if $month < 1 or $month > 12; die "Invalid day!" if $day <1 or $day > 31; print "Date OK!";
The date checking is rough and ready as it does not check for leap years and allows for instance 31 days in February!. You can easily fix this by either coding some decent checking or using the check_date() function of the Date::Calc module.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: unpacking - html re-encoding?
by tachyon
in thread unpacking - html re-encoding?
by Mac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |