It sounds like you want a simple state machine. You're checking for duplicates and also checking for two parts of a tuple.
No big deal. Here are some hints:
First off, use split(/,/, $_) to break up the line.
Then for converting lat and longitude formats:
my @latitude = split(/\./, $_[5]);
my $latstring = sprintf("%8s", ($latitude[0] . $latitude[1])) ;
And finally for the state machine (totally untested):
while (<LOGFILE>) {
chomp $_;
if ($_[0] eq $lastline ) {
if ($_[0] eq "1sec CDMA Event DtiC(0)") {
#average those things or whatever you neeed to do
}elsif ( $_[0] eq "Generic Scanner PN Measurement DtiC(0)") {
#average those things or whatever you need to do
}
} else {
#determine which part of the tuple this line is and
#store Rxpower/add Rxpower and massage lat/long into strings
}
$lastline = $_[[0];
}
As I mentioned, all code is untested, but it's a starting point.
--
jpg
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.