#!/usr/bin/perl

# filelist.pl
#
# create list of files to retrieve from NWSTG

$lastfile = @ARGV[0]; #last file at NWSTG rounded to nearest 10 files
$localfile = @ARGV[1];   # last file stored locally

$endfile = $lastfile+5;

#we need to retrieve the most recent files we haven't retrieved already
#


#print "lastfile: $lastfile, localfile: $localfile, endfile: $endfile \n";


if ($localfile > $lastfile)
   {$localfile = $lastfile;
   }

for ($i = 0;$i < 5; $i++)  {

$myfile = $lastfile + $i;
if ($myfile > 250)
  {
  $myfile = $myfile-250;
  }
    print "sn.",prepend($myfile)," ";

}
print "\n";


sub prepend {
if ($_[0] < 1000) {
     $string = "0" . $_[0];
  }
  if ($_[0] < 100) {
     $string = "00" . $_[0];
     }
  if ($_[0] < 10) {
     $string = "000" . $_[0];
     }
     return $string;
      }

