[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

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


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