Thursday, April 14, 2011

Am I asleep; Have I slept?

I've been trying to hack this damn thing for weeks, but I finally got it.

And you know what, I'm celebrating by going to the SK lutheran church.

Killz baby, it killz.

I don't know how to add an attachment, so cut and paste I guess:

p.s. I don't remember where I got this sub but thanks whoever built the orig.








 #!/usr/bin/perl

use strict;
use warnings;

use Time::Local qw( timegm_nocheck );


print "Please enter the month you were born.\n\n
like this: 4 (for April) or 1 (for January)\n\n\n";
chomp(my $two = <STDIN>);
print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nNow the day of the month.\n\n\nlike this: 14 (for the 14th) or 13 (for the thirteenth)\n\n\n\n\n";
chomp(my $three = <STDIN>);
print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nNow the year\n
like this: 2006\n\n";
chomp(my $one = <STDIN>);


# birth_date_age(2006, 4, 28) for people born on April 28th, 2006.
sub birth_date_age {
  
   my $bday_y = $one;
   my $bday_m = $two;
   my $bday_d = $three;
   # ----------------------------------------
   # -- Get current date.

   my ($now_y, $now_m, $now_d) = (localtime)[5,4,3];
   $now_y += 1900;
   $now_m++;
   my $date_now = timegm_nocheck(0,0,0, $now_d, $now_m-1, $now_y);

   # ----------------------------------------
   # -- Get next birthday.

   my $date_next = timegm_nocheck(0,0,0, $bday_d, $bday_m-1, $now_y);

   $date_next = timegm_nocheck(0,0,0, $bday_d, $bday_m-1, $now_y+1)
      if $date_next <= $date_now;

   my ($next_y) = (gmtime($date_next))[5];
   $next_y += 1900;

   # ----------------------------------------
   # -- Get prev birthday.

   my $prev_y = $next_y - 1;
   my $date_prev = timegm_nocheck(0,0,0, $bday_d, $bday_m-1, $prev_y);

   # ----------------------------------------
   # -- Calculate age and others

   my $age = $next_y - $bday_y - 1;

   my $days_to   = ($date_next - $date_now) / (24*60*60);
   my $days_from = ($date_now - $date_prev) / (24*60*60);

   return ("\nYou are $age years", " and $days_from days old\n\n\nGet busy living or get busy dying.\n

Written by unknown, whacked by Johnny Taaka");
}

print"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",  &birth_date_age($one, $two, $three);

No comments:

Post a Comment