D
deadpickle
What I want to do is search a text file for the correct station ID. I
hope this is clearer from the code. I run it and it returns the correct
values but I get the warning "Odd number of elements in hash assignment
at search1.pl line 15, <ID> line 6." Im not sure what this means. Any
help?
Also I want to pass a few variables to a subroutine but am not sure how
to do this.
Text file
===================================================================
KLNK 261412Z 04011KT 3/4SM R36/5500VP6000FT BR OVC003 07/06 A2992 RMK
AO2
KCHS 131656Z 15009KT 10SM -RA FEW027 BKN044 24/20 A2994 RMK AO2 RAB44
SLP137 P0000 T02440200
KEMP 101653Z AUTO 33016KT 10SM BKN065 BKN090 07/00 A2993 RMK AO2 PK WND
33027/1559 SLP136 T00670000
KHSI 101653Z AUTO 36015KT 7SM OVC007 03/01 A3013 RMK AO2 SLP214
T00280006
KRSL 101653Z AUTO 35021G27KT 10SM BKN018 OVC030 06/00 A3009 RMK AO2 PK
WND 35027/1649 SLP194 T00560000
KRWL 101653Z AUTO 25018G22KT 10SM CLR M02/M07 A3027 RMK AO2 SLP273
T10171067
My Program
===================================================================
#=========================================================
# This code is used to search a text file for the correct
# ASOS sites are then runs the metarcode subroutine to
# create the placefile that GRLevel3 needs.
#=========================================================
use strict;
use warnings;
$\ = "\n";
# Open the text file containing the stations
open (ID, "stations.txt");
while (my $stations = <ID>) {
my @station = split (/\n/,$stations); # enter each line into an array
foreach (@station) { # Search the array for the correct stations
print $_;
if (my %stid = $_ =~ m/^KRWL/) {
my $id = $_;
print $id;
}
}
}
This is a prelimanary program so it does not pass the variables to the
subroutine. I want to pass three variables to the subroutine: 1) the
array resulting from the search;2) the latitude of the site; 3) the
longitude. THe lat and long need to be inserted into a variable on the
subroutine and so does the array. I am not sure on how to do this and
any help wouild be great. Thanks.
hope this is clearer from the code. I run it and it returns the correct
values but I get the warning "Odd number of elements in hash assignment
at search1.pl line 15, <ID> line 6." Im not sure what this means. Any
help?
Also I want to pass a few variables to a subroutine but am not sure how
to do this.
Text file
===================================================================
KLNK 261412Z 04011KT 3/4SM R36/5500VP6000FT BR OVC003 07/06 A2992 RMK
AO2
KCHS 131656Z 15009KT 10SM -RA FEW027 BKN044 24/20 A2994 RMK AO2 RAB44
SLP137 P0000 T02440200
KEMP 101653Z AUTO 33016KT 10SM BKN065 BKN090 07/00 A2993 RMK AO2 PK WND
33027/1559 SLP136 T00670000
KHSI 101653Z AUTO 36015KT 7SM OVC007 03/01 A3013 RMK AO2 SLP214
T00280006
KRSL 101653Z AUTO 35021G27KT 10SM BKN018 OVC030 06/00 A3009 RMK AO2 PK
WND 35027/1649 SLP194 T00560000
KRWL 101653Z AUTO 25018G22KT 10SM CLR M02/M07 A3027 RMK AO2 SLP273
T10171067
My Program
===================================================================
#=========================================================
# This code is used to search a text file for the correct
# ASOS sites are then runs the metarcode subroutine to
# create the placefile that GRLevel3 needs.
#=========================================================
use strict;
use warnings;
$\ = "\n";
# Open the text file containing the stations
open (ID, "stations.txt");
while (my $stations = <ID>) {
my @station = split (/\n/,$stations); # enter each line into an array
foreach (@station) { # Search the array for the correct stations
print $_;
if (my %stid = $_ =~ m/^KRWL/) {
my $id = $_;
print $id;
}
}
}
This is a prelimanary program so it does not pass the variables to the
subroutine. I want to pass three variables to the subroutine: 1) the
array resulting from the search;2) the latitude of the site; 3) the
longitude. THe lat and long need to be inserted into a variable on the
subroutine and so does the array. I am not sure on how to do this and
any help wouild be great. Thanks.