#! /usr/bin/perl

##  this perl pgm selects SXUS72 bulletins from the shef_other file    
##  this perl pgm searches the shef_other file for AFOS bulletins when the
##  2nd line of the WMO header is RR7 or the 1st line of the WMO header is
##  SRUS27 KZ  (a bulletin of FAA ASOS sites with hourly precip reports)

undef $/ ;
$/ = "\x0d\x0a\x03" ;    # redefine the end of a logical record

while (<>) 
  { 
    if  (/SXUS72/)       # if an AFOS SXUS72 bulletin, send to output file
        { print $_ ; }

    if  (/RR7/)          # if an AFOS RR7 bulletin, change any .Y to .A
        { s/\.Y/\.A/g; print $_ ; }

                         # if an FAA SRUS27 bulletin, remove the special
                         # character before the .A or .Y and change .Y to .A
    if  (/SRUS27 KZ/)
       { s/\x1e././g; s/\.Y/\.A/g; print $_; }
  }
 
