#!perl -w

use strict;
no strict "vars";

use Date::DateCalc qw(decode_date date_to_short dates_difference);

print "\n";

$ok = 0;
while (! $ok)
{
    print "Please enter the date of your birthday (day-month-year): ";
    $date = <STDIN>;
    print "\n";
    if (($yy1,$mm1,$dd1) = decode_date($date))
    {
        $datestr = date_to_short($yy1,$mm1,$dd1);
        print "Your date is: $datestr\n";
        print "\n";
        print "Is that correct? (Yes/No) ";
        $response = <STDIN>;
        print "\n";
        $ok = ($response =~ /^Y/i);
    }
}
print "Your birthday is: $datestr\n";
print "\n";

$ok = 0;
while (! $ok)
{
    print "Please enter today's date (day-month-year): ";
    $date = <STDIN>;
    print "\n";
    if (($yy2,$mm2,$dd2) = decode_date($date))
    {
        $datestr = date_to_short($yy2,$mm2,$dd2);
        print "Your date is: $datestr\n";
        print "\n";
        print "Is that correct? (Yes/No) ";
        $response = <STDIN>;
        print "\n";
        $ok = ($response =~ /^Y/i);
    }
}
print "Today's date is: $datestr\n";
print "\n";

$days = dates_difference($yy1,$mm1,$dd1,$yy2,$mm2,$dd2);
print "You are $days days old.\n";
print "\n";

__END__

