i have a perl script that i created, and what it needs to do is process a bunch of files and put the info from those files into a different format into a summary file. when processing, i need to take out all of the <br> and i come into a problem. i use this
foreach $line (@fields_add){
$line =~ s/<br>/ /i;
}
to replace the <br> with a space, but it does not get all of them.
basically if you look at the perl script, what it does is just seperate the lines of the files at the occurance of ;; and then puts them in a format for another script. so, if you look at where it shows
1/2<br>This run is too short to be a segment;;
that <br> will be removed, but if you look at
<br>Lat/lons are for start and stop of imaging;;
it will skip that <br>... anyone know why this is not working correctly???
file to be processed 'f000411t01.log' :
f000411t01;;p01_r01;;1;;1;;Preflight;;;;Jack Holbrook;;;;;;;;;;1738;;1740;;4 - Pre/Postflight;;;;
f000411t01;;p02_r01;;2;;1;;Mobile Check;;;;Dee Porter;;;;;;;;;;19:07:09;;19:09:01;;6 - Tarmac Check;;;;
f000411t01;;p03_r01;;3;;1;;Maui 3-A, HI;;02072;;Gene Carl Feldman;;20-49.6;;157-8.6;;20-44.1;;156-22.7;;20:26:51;;20:34:29;;1 - Science;;28/27;;
f000411t01;;p03_r02;;3;;2;;Molokai 2-A, HI;;02072;;Gene Carl Feldman;;21-5.6;;156-42.2;;21-10.3;;157-20.8;;20:41:41;;20:47:53;;1 - Science;;97/98;;
f000411t01;;p03_r03;;3;;3;;MODIS/MOBY;;02026;;Green;;20-53.55;;157-5.1;;20-36.9;;157-5.4;;21:06:30;;21:19:53;;1 - Science;;Control point = 20-49.6, 157-08.25<br>Looking at MOBY @ approx. 21:14:33<br>Lat/lons are for start and stop of imaging;;
f000411t01;;p03_r04;;3;;4;;Hawaii 4-A, HI;;02072;;Gene Carl Feldman;;20-0.9;;156-0.3;;19-59.0;;155-42.1;;21:31:15;;21:35:01;;1 - Science;;58/57;;
f000411t01;;p03_r05;;3;;5;;Hawaii 5-B, HI;;02072;;Gene Carl Feldman;;19-54.6;;155-47.6;;19-56.5;;156-5.3;;21:40:52;;21:44:21;;1 - Science;;60/59<br>5-A was flown on 000410;;
f000411t01;;p03_r06;;3;;6;;Oahu 4-A, HI;;02072;;Gene Carl Feldman;;21-18.0;;157-45.8;;21-19.8;;158-18.1;;22:03:02;;22:06:03;;1 - Science;;7/8;;
f000411t01;;p03_r07;;3;;7;;Oahu 3-A, HI;;02072;;Gene Carl Feldman;;21-25.8;;158-9.3;;21-23.9;;157-53.4;;22:11:37;;22:15:00;;1 - Science;;5/6;;
f000411t01;;p03_r08;;3;;8;;Oahu 1-A, HI;;02072;;Gene Carl Feldman;;21-27.8;;157-45.7;;21-29.9;;158-3.0;;22:20:21;;22:23:47;;1 - Science;;1/2<br>This run is too short to be a segment;;
f000411t01;;p03_r09;;3;;9;;Niihau 2-A, HI;;02072;;Gene Carl Feldman;;21-49.7;;159-59.4;;21-52.1;;160-16.9;;22:40:03;;22:43:29;;1 - Science;;47/48;;
f000411t01;;p03_r10;;3;;10;;Kauai 5-A, HI;;02072;;Gene Carl Feldman;;21-59.5;;160-3.5;;21-54.7;;159-29.0;;22:51:15;;22:57:22;;1 - Science;;44/43;;
f000411t01;;p04_r01;;4;;1;;Postflight;;;;Chuck Sarture;;;;;;;;;;00:40:00;;00:42:00;;4 - Pre/Postflight;;;;
perl script 'convert.pl' :
Code:
#!/usr/bin/perl
$LID = 100;
$FLT = 0;
$F_PATH = 1;
$LAT1 = 7;
$LON1 = 8;
$LAT2 = 9;
$LON2 = 10;
@filelist = <f*.log>;
#@filelist = <f000411t01.log>;
$arc_file = "Arc_file";
$info_file = "info_file";
%out_dat = ();
$hide = 0;
if($ARGV[0] eq "-h" || $ARGV[0] eq "-H"){
$hide = 1;
}
open (OUTPUT, ">$arc_file") || die "Cant create $arc_file";
print($a);
foreach $F (@filelist){
if($hide == 0){
print("Processing file $F...\n");
}
open (FILE, $F) || die "Cant open $arg_file";
while ($line = <FILE>) {
@fields = split(/;;/, $line);
if($fields[$LAT1]){
$LID++;
#first latitude and longitude
($lat1_d, $lat1_m) = split(/-/, $fields[$LAT1]);
$lat1_d += $lat1_m/60;
($lon1_d, $lon1_m) = split(/-/, $fields[$LON1]);
$lon1_d = ($lon1_d * -1) + (($lon1_m/60) * -1);
#second lat and lon
($lat2_d, $lat2_m) = split(/-/, $fields[$LAT2]);
$lat2_d += $lat2_m/60;
($lon2_d, $lon2_m) = split(/-/, $fields[$LAT2]);
$lon2_d = ($lon2_d * -1) + (($lon2_m/60) * -1);
#output to lat/lon file
print (OUTPUT "$LID\n");
print (OUTPUT "$lon1_d\t$lat1_d\n");
print (OUTPUT "$lon2_d\t$lat2_d\n");
print (OUTPUT "end\n");
#store the rest of the info into a hash
$UID = "$fields[0]_$fields[1]";
@fields_add = @fields[1 .. 6, 11 .. $#fields];
#take out the <br>
foreach $line (@fields_add){
$line =~ s/<br>/ /i;
}
$out_dat{$LID} = (join("\t", $UID, join("\t", @fields_add)));
}
}
close(FILE);
}
print (OUTPUT "end\n");
close(OUTPUT);
open(OUTPUT, ">$info_file");
for $key (sort {$a<=>$b} keys %out_dat){
print(OUTPUT "$key\t$out_dat{$key}\n");
}