#!/usr/local/bin/perl -w # # birthday # # Build a birthday list for the calendar program. # # To do anniversaries, look for entries which have an anniversary # entry. If it does not have a InResidence entry, emit the appropriate # entry. Modify the ResidenceName (if present) to account for # possible children. # # The home for this program is at: # http://mordred.ao.com/phone.list/ # # Dave Regan # 9 May 2000 # regan@mordred.ao.com # use strict; ### ### Configuration ### use vars qw($DataFile $Version); $Version = 'birthday v0.10 regan@ao.com'; $DataFile = $ENV{'HOME'} . '/Notes/phone.dat'; # Text data file ### ### Main program ### my(%attribute, $day, $mon, $name, $value, $year); open(DATA, "<$DataFile") || die "Cannot open $DataFile: $!"; while () { chomp; next if (/^\s*$/ || /^\s*#/); if (/^%%/) { if (defined($attribute{'Birthday'}) && $attribute{'Birthday'} =~ /(\d+) (\w\w\w)\w*\s*(\d*)/) { ($day, $mon, $year) = ($1, $2, $3); $year = "" unless ($year > 1800); ($name = $attribute{'Name'}) .= "'"; $name .= "s" if ($name !~ /s'$/); printf("%-3.3s %2d [- 7]\t$name birthday $year\n", $mon, $day); } if (defined($attribute{'Anniversary'}) && !defined($attribute{'InResidence'}) && $attribute{'Anniversary'} =~ /(\d+) (\w\w\w)\w*\s*(\d*)/) { ($day, $mon, $year) = ($1, $2, $3); $year = "" unless ($year > 1800); $name = $attribute{'Name'}; $name = $attribute{'ResidenceName'} if (defined($attribute{'ResidenceName'})); $name =~ s/ and .*//; $name .= "'"; $name .= "s" if ($name !~ /s'$/); printf("%-3.3s %2d [- 7]\t$name anniversary $year\n", $mon, $day); } undef %attribute; } elsif (/^([^=]*?)\s*=(.*)/) { ($name, $value) = ($1, $2); $attribute{$name} = $value; if ($value =~ /Day after Thanksgiving/) { $attribute{$name} = "26 November 1982"; } } }