LordAvatar has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A string parsing question
by suaveant (Parson) on Apr 20, 2001 at 19:12 UTC | |
|
Re: A string parsing question
by Sifmole (Chaplain) on Apr 20, 2001 at 19:35 UTC | |
|
Re: A string parsing question
by jeroenes (Priest) on Apr 20, 2001 at 19:13 UTC | |
by suaveant (Parson) on Apr 20, 2001 at 19:23 UTC | |
|
Re: A string parsing question
by LordAvatar (Acolyte) on Apr 20, 2001 at 22:27 UTC | |
|
Re: A string parsing question
by Sifmole (Chaplain) on Apr 20, 2001 at 19:26 UTC | |
by suaveant (Parson) on Apr 20, 2001 at 19:29 UTC | |
by Sifmole (Chaplain) on Apr 20, 2001 at 19:36 UTC | |
by Sifmole (Chaplain) on Apr 20, 2001 at 19:29 UTC |