#!/usr/local/bin/perl # # Produce Yahrzeit Letters # require "getopts.pl"; require "fmtsub"; $seq="aa01"; @hebrew_months= ("Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishri", "Heshvan","Kislev","Teveth","Shevat","Adar I","Adar II"); foreach (@hebrew_months) { push (@hmos,"\L$_"); } $month = shift (@ARGV); foreach (@hmos) { $mo++; if ("\L$month" eq substr($_,0,length($month))) { $heb_month=$hebrew_months[$mo-1]; $mno=$mo; last; } } #print "processing month #$mno $month\n"; unless ($mno) { print "Bad paramater : $month\n"; exit; } while () { push (@tmpl1,$_); } while (<>) { if (/:end:/) { if($have_data) { &fmt("",\@mydata); ($yd,$ym,$yy)=split(/[ \t]+/,$key{"yahrhebdate"}); $tmo=$mo=0; foreach (@hmos) { $mo++; if ("\L$ym" eq substr($_,0,length($ym))) { $tmo=$mo; last; } } if ($tmo) { if (! $yy && ( ($tmo == 12 && length($ym < 6)) #ambiguous ADAR || (($tmo == 8 || $tmo == 9) && ($yd == 30)))) { print "Ambiguous date: $yd $ym for $key{membername}\n"; } else { $yy = $yy ? $yy : "5759"; if ( $tmo == $mno ) { ($engdate,$shab)=`test.cl "( $tmo $yd $yy )"`; chop($engdate); chop($shab); $key{yahrengdate}=$engdate; $key{yahrshab}= $shab; $t=$key{relation}; $key{relation}= "\L$t"; &form_letter; $relationname = $key{relationname}; $relation = $key{relation}; $relation = "\u$relation"; $membername = $key{membername}; $hebd = $key{yahrhebdate}; $engd = $key{yahrengdate}; $engd =~ s/,.*//; $shab =~ s/Shabbos //; $shab =~ s/Parashas //; write; } } } else { print STDERR "Unrecognized month $ym for $key{membername}\n"; } $have_data=0; @mydata = (); next; } } elsif (/:begin:/) { next; } else { push (@mydata,$_); $have_data=1; } } sub form_letter { $file="/tmp/yi_".$seq++; @data=(); while (($key,$data) = each %key) { push(@data,":$key: $data\n"); } @tmpl=@tmpl1; open (OUT,">$file.dat") || die "opening $file.dat"; print OUT @data; close OUT; system("fmt -o $file.t $file.dat"); system("psprt -mm $file.t"); unlink ("$file.t"); unlink ("$file.dat"); system ("mv $file.t.ps $file.ps"); # system ("mylp $file.ps"); # unlink "$file.ps"; } format STDOUT_TOP = @<<<<<<<<<<<<<<<<<<<<<<<<<<<< Yahrzeits for @<<<<<<<<<<<<< `date +'%B %e, %Y`,$heb_month Name Relation Person observing Dates Shabbos ================================================================================================================ . format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<@<<<<<<<<<<<<< $relationname, $relation, $membername, $hebd, $engd,$shab .