#!/usr/bin/perl -w #mercury.pl-how old am I in Mercury Years. use Time::localtime(); #for ctime use Time::Local; #for timelocal use POSIX; #for floor #length of Mercury year in earth days $mercuryRevolution = 87.97; #get birthday stats for Oct 1, 1977 $birthDay = 1;$birthMonth=9;$birthYear=77; $birthTime = timelocal(0,0,0,$birthDay,$birthMonth,$birthYear); $currentTime = time(); $timeAlive = $currentTime - $birthTime; $daysAlive = POSIX::floor($timeAlive / (24 * 60 * 60)); $mercuryYears = POSIX::floor($daysAlive / $mercuryRevolution); $nextMercuryBday = $daysAlive % $mercuryRevolution; $nextBirthDate = ctime(time()+ ($nextMercuryBday *24*60*60)); #strip hours,minutes,seconds from ctime string $nextBirthDate =~ s/(\w+\s\w+\s\d+)(\s\S+\s)(\w*)/$1,$3/; print "\nYou are ".$mercuryYears." Mercurian Years old", "\nYour next Mercurian Birthday is in " . $nextMercuryBday . " days\n", "on ". $nextBirthDate