[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/yahrzeit/old/ -> yahrltrs.bak (source)

   1  #!/usr/local/bin/perl
   2  
   3  #
   4  #  Produce Yahrzeit Letters
   5  #  
   6  
   7  open (STDOUT, ">/tmp/summary");
   8  require "getopts.pl";
   9  require "fmtsub";
  10  $seq="aa01";
  11  
  12  @hebrew_months=  ("Nisan","Iyar","Sivan","Tammuz","Av","Elul","Tishri",
  13       "Heshvan","Kislev","Teveth","Shevat","Adar I","Adar II");
  14  foreach (@hebrew_months) {
  15      push (@hmos,"\L$_");
  16  } 
  17  
  18  
  19  $month = shift (@ARGV);
  20  foreach (@hmos) {
  21    $mo++;
  22      if ("\L$month" eq substr($_,0,length($month))) {
  23          $heb_month=$hebrew_months[$mo-1];
  24          $mno=$mo;
  25          last;
  26      }
  27  }
  28  print "processing month #$mno $month\n";
  29  unless ($mno) {
  30      print "Bad paramater : $month\n";
  31      exit;
  32  } 
  33  
  34  while (<DATA>) {
  35      push (@tmpl1,$_);
  36  } 
  37  
  38  
  39  while (<>) {
  40      if (/:end:/) {
  41          if($have_data) { 
  42              &fmt("",\@mydata);
  43              $yy=0;
  44              ($yd,$ym)=split(/[ \t]+/,$key{"yahrhebdate"},2);
  45              if($ym =~ /\s*(\d+)$/) { $yy =$1; }
  46              $ym =~ s/\s*(\d+)$//;
  47  
  48              $tmo=$mo=0;
  49              foreach (@hmos) {
  50                  $mo++;
  51                  if ("\L$ym" eq substr($_,0,length($ym))) {
  52                      $tmo=$mo;
  53                      last;
  54                  }
  55              } 
  56              if ($tmo) {
  57                  if (! $yy && ( ($tmo == 12 && $ym eq "Adar")   #ambiguous ADAR
  58                                 || (($tmo == 8 || $tmo == 9) && ($yd == 30)))) {
  59                              print "Ambiguous date: $yd $ym for $key{membername}\n";
  60                  } else {
  61                      $yy = $yy ? $yy : "5759";
  62                      if ( $tmo == $mno ) {
  63                          ($engdate,$shab)=`test.cl "( $tmo $yd $yy )"`;
  64                          chop($engdate);
  65                          chop($shab);
  66                          $key{yahrengdate}=$engdate;
  67                          $key{yahrshab}= $shab;
  68                          $t=$key{relation};
  69                          $key{relation}= "\L$t";
  70                          $relationname = $key{relationname};
  71                          $relation = $key{relation};
  72                          $relation = "\u$relation";
  73                          $membername = $key{membername};
  74                          $hebd = $key{yahrhebdate};
  75                          $engd = $key{yahrengdate};
  76                          $engd =~ s/,.*//;
  77                          $key{var1}=1;
  78                          if ($shab =~ /NIL/) {
  79                              $shab = "Yom Tov";
  80                              $key{yahrshab}= $shab;
  81                              $key{var1}=0;
  82                              if ( $tmo == 7 ) { 
  83                                  $key{note1} = "At your request a `kail male rachamim' prayer may be recited on the shabbos before Yom Kippur."; } 
  84                              elsif ( $tmo == 1  ) {
  85                                  $key{note1} = "At your request a `kail male rachamim' prayer may be recited on the shabbos before the start of the month of Nissan." ; }
  86                          }
  87                          $shab =~ s/Shabbos //;
  88                          $shab =~ s/Parashas //;
  89                          &form_letter; 
  90                          write;
  91                      } 
  92                  } 
  93              } else {
  94                  print STDERR "Unrecognized month $ym for $key{membername}\n";
  95              }
  96              $have_data=0;
  97              @mydata = ();
  98              next;
  99          }
 100      } elsif (/:begin:/) { next; 
 101      } else {
 102          push (@mydata,$_);
 103          $have_data=1;
 104      }
 105  }
 106  
 107  sub form_letter {
 108      $file="/tmp/yi_".$seq++;
 109      @data=();
 110      while (($key,$data) = each %key) {
 111          push(@data,":$key: $data\n");
 112      } 
 113      @tmpl=@tmpl1;
 114      open (OUT,">$file.dat") || die "opening $file.dat";
 115      print OUT @data;
 116      close OUT;
 117    system("fmt -o $file.t $file.dat");
 118      system("psprt -mm $file.t");
 119      unlink ("$file.t");
 120      unlink ("$file.dat");
 121    system ("mv $file.t.ps $file.ps");
 122  #  system ("mylp $file.ps");
 123  #  unlink "$file.ps";
 124  }
 125  
 126  
 127  format STDOUT_TOP =
 128  
 129  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<          Yahrzeits for @<<<<<<<<<<<<<   
 130  `date +'%B %e, %Y`,$heb_month
 131  
 132  Name                             Relation        Person observing               Dates                 Shabbos
 133  ================================================================================================================
 134  
 135  .
 136  
 137  format STDOUT =
 138  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<@<<<<<<<<<<<<<
 139  $relationname,     $relation,          $membername,      $hebd, $engd,$shab
 140  
 141  .


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7