D
deadpickle
This is what I want the program to do:
1. Read in a file containing:
KBQP 071845Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KBQP 071905Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KHLR 071856Z AUTO 19010KT 10SM CLR 22/13 A3007 RMK AO2 SLP179
KBQP 071925Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
2. Search for strings beginning with K at the beginning
EXAMPLE: next unless $obs =~ m/^(K)/;
3. When they are found load them into an array
EXAMPLE: my @a = split(" ", $obs);
4. Next, continue to search the file. But instead of searching for any
string beginning with K it instead searches for and string beginning
with the first four letters of the station ID.
EXAMPLE: First time through finds that $a[0] = KBQP
Continues through the file until it finds
another KBQP
5. After it has found another station ID with the same name as shown
in #4, it then checks the next value in BOTH arrays and compares them.
The object is to see which string is the newest.
6. The newer string gets wrote to the array and the program continues
to search for the same ID.
7. If no other similar IDs are found, go back to step 1.
The flow should look something like this:
Search for "K"
Found "KBQP" -> Load into array
Search for "KBQP"
Found "KBQP" -> comparing times of the observations
Second "KBQP" found is newer -> replacing the array with newer "KBQP"
Search for "KBQP"
If No newer "KBQP" found -> Search For "K"
I hope this is clear. My problem is that I have no clue how to do this
after step 3. Any help would be appreciated.
Code So far:
==============================================================
use strict;
use warnings;
$\ = "\n";
my $wmo = "07020719f.wmo";
open OUT,'>', 'sub.txt' or die "cannot open 'sub.txt' $!";
open WMO, '<', $wmo;
while (my $obs = <WMO>) {
next unless $obs =~ m/^(K)/;
my @a = split(" ", $obs);
}
close OUT;
1. Read in a file containing:
KBQP 071845Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KBQP 071905Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
KHLR 071856Z AUTO 19010KT 10SM CLR 22/13 A3007 RMK AO2 SLP179
KBQP 071925Z AUTO 35003KT 7SM OVC012 14/12 A3018 RMK AO2=
2. Search for strings beginning with K at the beginning
EXAMPLE: next unless $obs =~ m/^(K)/;
3. When they are found load them into an array
EXAMPLE: my @a = split(" ", $obs);
4. Next, continue to search the file. But instead of searching for any
string beginning with K it instead searches for and string beginning
with the first four letters of the station ID.
EXAMPLE: First time through finds that $a[0] = KBQP
Continues through the file until it finds
another KBQP
5. After it has found another station ID with the same name as shown
in #4, it then checks the next value in BOTH arrays and compares them.
The object is to see which string is the newest.
6. The newer string gets wrote to the array and the program continues
to search for the same ID.
7. If no other similar IDs are found, go back to step 1.
The flow should look something like this:
Search for "K"
Found "KBQP" -> Load into array
Search for "KBQP"
Found "KBQP" -> comparing times of the observations
Second "KBQP" found is newer -> replacing the array with newer "KBQP"
Search for "KBQP"
If No newer "KBQP" found -> Search For "K"
I hope this is clear. My problem is that I have no clue how to do this
after step 3. Any help would be appreciated.
Code So far:
==============================================================
use strict;
use warnings;
$\ = "\n";
my $wmo = "07020719f.wmo";
open OUT,'>', 'sub.txt' or die "cannot open 'sub.txt' $!";
open WMO, '<', $wmo;
while (my $obs = <WMO>) {
next unless $obs =~ m/^(K)/;
my @a = split(" ", $obs);
}
close OUT;