Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
works ok I would say, but I guess it is not 100% accurate (since I assume years of 365 days and I do not take into account months and days of birth and death.use strict; use warnings; use Date::Calc qw(:all); my $date_birth = '1999-12-13'; my $date_death = '2080-05-21'; my @array_birth = split(/-/, $date_birth); my @array_death = split(/-/, $date_death); my $dd = Delta_Days(@array_birth, @array_death); my $years_alive = sprintf("%.1f", $dd/365); print $years_alive,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date::Calc in years?
by choroba (Cardinal) on Oct 18, 2018 at 09:22 UTC | |
by Anonymous Monk on Oct 18, 2018 at 09:23 UTC | |
|
Re: Date::Calc in years?
by BillKSmith (Monsignor) on Oct 18, 2018 at 19:18 UTC | |
|
Re: Date::Calc in years?
by thanos1983 (Parson) on Oct 19, 2018 at 22:41 UTC | |
|
Re: Date::Calc in years?
by Anonymous Monk on Oct 18, 2018 at 09:18 UTC | |
by Anonymous Monk on Oct 18, 2018 at 09:20 UTC |