[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/yahrzeit/old/ -> yahrenv (source)

   1  #!/usr/local/bin/perl
   2  
   3  #
   4  #  Produce Yahrzeit Envelopes
   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                          unless ($key{memstatus} =~ /deceased/i) {
  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                          }
  71                      } 
  72                      %key=(); %relation=(); @mydata=();
  73                  } 
  74              } else {
  75                  print STDERR "Unrecognized month $ym for $key{membername}\n";
  76              }
  77              $have_data=0;
  78              @mydata = ();
  79              next;
  80          }
  81      } elsif (/:begin:/) { next; 
  82      } else {
  83          push (@mydata,$_);
  84          $have_data=1;
  85      }
  86  }
  87  
  88  sub form_letter {
  89      $file="/tmp/yi_".$seq++;
  90      @data=();
  91      while (($key,$data) = each %key) {
  92          push(@data,":$key: $data\n");
  93      } 
  94      @tmpl=@tmpl1;
  95      open (OUT,">$file.dat") || die "opening $file.dat";
  96      print OUT @data;
  97      close OUT;
  98    system("fmt -ttempl.env -o $file.t $file.dat");
  99      system("psprt $file.t");
 100      unlink ("$file.t");
 101      unlink ("$file.dat");
 102    system ("mv $file.t.ps $file.ps");
 103  #  system ("mylp $file.ps");
 104  }


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