The following script reads a file called warning.txt and extracts a string of latitude and longitude values from the file. The format of this string is: LAT1 LON1 LAT2 LON2 LAT3 LON3 up to a maximum of 20 LAT/LON pairs.
I would like to split the string and store each latitude in its own array and each longitude in its own array. Perhaps one way to do this would be to split the whole thing into an array and then make all LATs the odd elements and all LONs the even elements.
Any suggestions and code assistance for how to use split to do this would be appreciated.
Thank you.
I would like to split the string and store each latitude in its own array and each longitude in its own array. Perhaps one way to do this would be to split the whole thing into an array and then make all LATs the odd elements and all LONs the even elements.
Any suggestions and code assistance for how to use split to do this would be appreciated.
Thank you.
Code:
#!/usr/bin/perl
open (WARNING, "/home/josh/warning.txt");
@arwarn = <WARNING>;
$stwarn = join('', @arwarn);
if($stwarn =~ m/LON(.*)\nTIME/) {
$coords = $1;
}