I am writing an application which parses information
from National Weather Service warnings.
The top 3 lines of each warning message appear as
follows:
I am trying to parse the third line and match the intermediate county codes to their parent state i.e 071 and 109 to NC.
Here is a snippet of code that I've written which reads the first and third lines. I've tried a few regexes for the third line but I haven't found a way to reliably add the state abbreviation to the intermediate codes. Right now I just get a list of all the codes like this:
NCC045 071 109 SCC021 087..etc.
I am trying to create:
NCC045 NCC071 NCC109 SCC021...etc.
Thanks for any help!
LINE: while(defined($line=<F>)) {
chomp $line;
$count++;
#first line
if ($line=~/\w{4}\d{2}\s+\w{4}\s+(\d{6})/) {
$issueTime = $1;
push @warningInfo, $issueTime;
}
#third line
if ($count==3) {
push @warningInfo, split/-/,$line
$count=0;
next FILE;
}
else {next;}
}
close F;
In reply to A string parsing question by LordAvatar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |