#!/usr/bin/perl

use strict;

### Variables

#  fdat -  file date
# outloc - output file location
#    per - number of days to process
# srcloc - source code location
#      y - EMC NWSLI filename

###

# declare variables

my (@files,@ref);
my ($cmd,$fdat,$y);
my (%ref);

# initialize file location variables

open(REF,"$ENV{PARMFILE}");
while (<REF>) {
    @ref = split /\s+/;
    $ref{$ref[0]} = $ref[1];
}
close REF;

@files = `ls -1 $ref{nwsliraw}/NWSLI*.TXT`;

foreach $y (@files) {
    ($fdat) = $y =~ /^.*(\d\d\d\d\d\d\d\d)\.TXT/;
    $y =substr($y,0,length($y)-1);
    if (! -e "$ref{outloc}/$fdat.NWSLI") {
       system("perl $ref{srcloc}/gaugeqc_NWSLIreformat_EMC.pl \-f $y \-o $ref{outloc}/$fdat.NWSLI");
#yl
       system("cp $fdat.NWSLI $ref{dataloc}/.");
#yl
    }
}







