#!/usr/bin/env perl # Perl script to turn on the volcanos on the world map used with worldwrap.sh which is put in pqact to automate use warnings; #Turn on warnings use Storable qw(store retrieve); #Add Storable module with functions $date_name=""; #Declare variables chdir('/home/wxp/sa/final') or die "could not open directory\n"; #Change directory to /home/wxp/sa/final while(<>){ #while file is piped in s/[\001\003\036\r]//g; #Remove non printable characters ^A ^C ^^ ^M if(/^ISSUED\:|^VOLCANO\:|^DTG\:/){ #Grab issue date/time and volcano name s/ISSUED\:\s+|VOLCANO\:\s+|DTG\:\s+|\d+\-\d+|\/|\.|VAAC.+$//g; #Remove keywords that we don't want in our string $date_name = $date_name . "$_"; #Store the lines in a single variable } } @date_name=split(/\n+/,$date_name); $date_name=""; @date_name=grep /\S/, @date_name; #Split on newline, delete $date_name variable, clear #empty elements in the array foreach(@date_name){ #Iterate thru @date_name array s/\s+//g; #Remove spaces from all elements of the array if(/\d+/){$date=$_; $date =~ s/Z//g;} #Assign date to $date variable and remove trailing Z if(/[A-Z]+/){$name=$_;} #Assign volcano name to $name variable } #print "$date $name\n"; %volcano_status = ("$name\n" => "$date ",); #Start hash with $date and $name store(\%volcano_status, 'stat') or die "Can't store %a in stat!\n"; #Use Storable module to add hash to file stat