Connecting Tech Pros Worldwide Forums | Help | Site Map

Current Date - Birth Date

stormrider's Avatar
Newbie
 
Join Date: Jan 2007
Posts: 10
#1: Jan 8 '07
Hi all,
I'm trying to implement a Perl structure.
My small program will do the followings;
Take the birth date of the user as input.
(Month's will be input as strings.)
Take the current time from the operating system.
Then calculate and display the age of the user as;
x years, x moonths and x days.
I also want to add a day/month counter,
so that the program will calculate and display the age of the user as;
x days, x months

So, I plan the program to work as follows;
Expand|Select|Wrap|Line Numbers
  1. Enter your birth date: 21 November 1975
  2. Enter the current date: 9 January 2007 //if i can't implement a get_system_time function
  3. Your age is: 31 year(s) 1 month(s) 19 day(s)
  4. You've been living for 11364 days or 378 months.
I'd be glad to hear some help about this small implementation.
Thanks all..

miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#2: Jan 9 '07

re: Current Date - Birth Date


Are all the functions and modules that you'll need:

http://perldoc.perl.org/functions/localtime.html
http://search.cpan.org/search?query=Date::Calc
http://perldoc.perl.org/POSIX.html
stormrider's Avatar
Newbie
 
Join Date: Jan 2007
Posts: 10
#3: Jan 14 '07

re: Current Date - Birth Date


Thank you for the functions miller..

Can anyone please also send me a body for my program.
I am really new at Perl and wondered how a structure works like my example.
I searched some code for this but couldn't find something alike.
If anyone posts some solution code, I'd like to examine it step-by-step,
and compile it on my mind for study..
Thank you all..
miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#4: Jan 16 '07

re: Current Date - Birth Date


No, people will not write your program for you.

This is obviously a homework assignment, as I've been asked this exact question in another forum. Write it yourself, and if you a specific problem feel free to post the code that you're having trouble with.

Don't expect people to write your code for you. I've already given you links to all the functions and modules you will need.
stormrider's Avatar
Newbie
 
Join Date: Jan 2007
Posts: 10
#5: Jan 22 '07

re: Current Date - Birth Date


Ohh.. I think I was misunderstood.
Anyway, thanks again for your interest..
Reply