#!/usr/local/bin/perl # # DeleteStations # 1996/04/09 W. Prescott # # Read StationsToExclude file. # Delete corresponding qm files. # # Mods: # Check for input start & stop dates # ---------------------------------- if ($#ARGV != -1) { print("Usage: DeleteStations\n"); exit 1; } # Check for existence of Exclude list # ----------------------------------- if (!-e "StationsToExclude") { print("DeleteStations: No stations deleted\n"); exit; } # Read list of stations to be deleted # ----------------------------------- open(HDL,"StationsToExclude"); @StationList = (); while () { $Station = $_; if (substr($Station,-1) eq "\n") { chop($Station);} push (@StationList,$Station); } close (HDL); # Read list of qm files # --------------------- opendir(HDL,"."); @FileList = grep (/.*\.qm$/,readdir(HDL)); close (HDL); # Look for Excluded stations in qm names # -------------------------------------- foreach $Station (@StationList) { foreach $File (@FileList) { $Position = index($File,$Station); if ($Position != -1) { system ("rm $File"); print("DeleteStations: $File deleted\n"); } } } exit;