my $ua = init_lwp();
my $uri = create_query2($url, $newdate);
my $resp_dat = execute_query($ua, $uri);
print $resp_dat;
####
my $ua = init_lwp();
my $uri = create_query2($url, $newdate);
my $resp_dat = execute_query($ua, $uri);
subgen($resp_dat);
####
sub subgen {
my($aref) = @_;
my($cur_segno) = 0;
my(@sst) = ();
#open(FILE, my $aref); #or die "Cannot open: $file\n";
my $hdr = <>; #read in the first line
chomp $hdr;
my @colnames = split /, ?/, $hdr; #split the header into an array
open GENFILE, '>genfile.txt';
open INFOFILE, '>infofile.txt';
my $sst_mean;
my %fronts;
while (<>) {
chomp;
next unless s/\"//g; # this will skip the first line and remove any "
my(@colvalues) = split /, ?/; #read in the data
@fronts{@colnames} = @colvalues;
if ($fronts{segno2} == $cur_segno) {
print GENFILE "$fronts{lon}, $fronts{lat}\n";
push(@sst, $fronts{sst});
} else {
if ($cur_segno != 0) {
print GENFILE "END\n";
print GENFILE "$fronts{segno2}\n",
"$fronts{lon}, $fronts{lat}\n";
$sst_mean = calc_mean( \@sst );
print INFOFILE "$sst_mean\n",
"$fronts{segno2}, ";
} else {
print GENFILE "$fronts{segno2}\n",
"$fronts{lon}, $fronts{lat}\n";
print INFOFILE "$fronts{segno2}, ";
}
$cur_segno = $fronts{segno2};
@sst = ();
}
print GENFILE "END\n";
}
close(FILE);
close(GENFILE);
close(INFOFILE);
}