use strict; use warnings; use DateTime; use IO::Prompt::Tiny qw( prompt ); # Get a DateTime object for birthday and now based on user input. my( $bday, $now ) = map { print "$_ date entry:\n"; DateTime->new( map { $_ => prompt "\tPlease enter $_:" } qw(day month year) ) } qw(Birth Today's); die "Birth date must be in the past.\n" unless $bday < $now; # Perform the math. print "\nYou are ", $bday->delta_days($now)->in_units('days'), " days old.\n";