#!/usr/bin/perl open(S, "< /home/set/addressbook/cumpleaƱos") || die; while() { # The following gibberish, in English, is # "Look for anything, note it, ignore any whitespace, then # look for something in the form XXXX.##.## which is # someone's birthdate in YYYY.MM.DD format (where we replace # the year with XXXX when I don't know the year of someone's # birth) if(/^\s*(.*)\s+([X0-9][X0-9][X0-9][X0-9]\.\d\d\.\d\d)/ && $_ !~ /^#/) { $bday_girl = $1; # Most are girls $date = $2; ($year,$month,$day) = split(/\./,$date); $time = time(); # Remove all trailing whitespace from the girl's name $bday_girl =~ s/\s+$//g; for($future = 0;$future <= 3; $future++) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time + $future * 86400); $mon++; if($mon == $month && $day == $mday) { if($future >= 2) { print "$bday_girl has a birthday in $future days\n"; } elsif($future == 1) { print "$bday_girl has a birthday tomorrow\n"; } elsif($future == 0) { print "Today is $bday_girl\'s birthday!\n"; } } #print "$bday_girl has bday on $month $day\n"; } } }