#!/usr/bin/perl # # birthdays.pl v0.0.2 - Outputs when someone's having a birthday # Copyright (C) 2009 Stian Skjæveland # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # Instructions: # # Create a file named ~/.birthdays with the following syntax: # # / # # Note that only the three first letters in month should be used, and # that has to match the output of the "date"-command. E.g.: # May 13/John Doe # # ...And while running the program (e.g. at startup) you'll get a notice # when John Doe has birthday. That's about it. # use strict; use Term::ANSIColor; my $birthfile="$ENV{'HOME'}/.birthdays"; my $systemdate=`date`; my (@birthlines, $birthcount, $i, $name, $date); open(BIRTHDAYS, "<$birthfile") || die("$0: $birthfile: $!\n"); $birthcount=@birthlines=; for ($i=0; $i<$birthcount; $i++) { ($date, $name)=split('/', $birthlines[$i]); if ($systemdate=~m/$date/) { chomp($name); if ($name) { print "\n"; print colored ['black on_white'], "$name"; print color 'reset'; print " has birthday today ($date)!"; print "\n\n"; exit(0); } } } close(BIRTHDAYS);