#!/usr/local/bin/perl # # pro_file_test.pl # routine to test out ".pro' file manipulation # v1.00/29May97/srg # # looks at all the files in the /data2/gbdata dir # processing those with a "moc" subdir and then # the ".pro" files found in the "moc's" # print "Content-type: text/html\n\n"; #needed for html interpretation #some definitions $topdir="/data2/gbdata"; # set data top directory chdir($topdir) or die "Cannot change to $topdir directory"; foreach $cruise_dir (<$topdir/*>) # get topdir filenames one at a time { # print "\n\nDEBUG/Crs_Dir: $cruise_dir\n"; $moc_dir = "$cruise_dir/moc"; # add /moc to the name # print "DEBUG/Moc_Dir: $moc_dir\n"; if(-e $moc_dir) # check if it exists and process { # o/p err msg if doesn't?? foreach $pro_file (<$moc_dir/*.pro>) # get the .pro files { # err msg if no pro's?? # print "DEBUG/Pro_file: $pro_file\n"; push (@pro_file_list, $pro_file); # push onto a list } } } # have list of all .pro files found - process them #$nfiles = @pro_file_list; # get a count of files #print "DEBUG/Number of Elements: $nfiles\n"; # o/p comments before starting to loop through files print "# GLOBEC .pro files\n"; print "# o/p by pro_file_test.pl v1.00, 29May97\n"; print "# TEST ONLY!!\n"; foreach $pro_file (@pro_file_list) { # print "\n\nDEBUG/Pro_File_List: $pro_file\n"; open(PROFILE,$pro_file); $i=0; while() { chop; $i++; # print "DEBUG/Line $i:$_\n"; if(index($_, "Tow:") != -1) { @towline = split; # print "DEBUG/TowLine: ",@towline,"\n"; $moctow = $towline[1]; $cruiseid = $towline[2]; # print "DEBUG/MocTow: $moctow\n"; # print "DEBUG/CruiseId: $cruiseid\n"; next; } elsif(index($_, "Date:") != -1) { @dateline = split; # print "DEBUG/DateLine: ",@dateline,"\n"; @cruisedate = split(/\//,$dateline[1]); $cruiseyear = $cruisedate[2] + 1900; # print "DEBUG/CruiseYear: $cruiseyear\n"; next; } elsif(index($_, "Temperature") != -1) { # print "DEBUG/TempLine: $_\n"; @templine = split; $tempprobe = $templine[3]; $condprobe = $templine[7]; # print "DEBUG/TempProbe: $tempprobe\n"; # print "DEBUG/CondProbe: $condprobe\n"; next; } elsif(index($_, "Pressure") != -1) { # print "DEBUG/PressLine: $_\n"; @pressline = split; $pressprobe = $pressline[3]; $oxyprobe = $pressline[7]; # print "DEBUG/PressProbe: $pressprobe\n"; # print "DEBUG/OxyProbe: $oxyprobe\n"; next; } elsif(index($_, "Transmissometer") != -1) { # print "DEBUG/TransLine: $_\n"; @transline = split; $trans = $transline[2]; $flour = $transline[5]; # print "DEBUG/Transmissometer: $trans\n"; # print "DEBUG/Flourometer: $flour\n"; next; } elsif(index($_, "time") != -1) { # print "DEBUG/TimeLine: $_\n"; next; } $tmp = $_; if($tmp = /(\d\.){1,4}/) # found a data line - end this loop { # print "DEBUG/DataLine at $i....\n $_\n"; $i=0; print "$pro_file $cruiseid $cruiseyear mocpro_level1.pl\n"; last; } } }