"Chris Stinemetz" wrote in message
Any help is appreciated.
Once I match HEH how can alter the program to print the contents that
are in the two lines directly above the match?
For example in this case I would like the print results to be:
**01 REPT:CELL 983 CDM 1, CCU 1, CE 5, HEH Timestamp: 10/10/11 00:01:18
[snip code and data]
I think the following should work.
Chris
#!/usr/bin/perl
use strict;
use warnings;
my $dt; # date_time
while (<DATA>) {
chomp;
if (m!^(\d\d/\d\d/\d\d \d\d:\d\d:\d\d)!) {
$dt = $1;
}
elsif (/HEH$/) {
print "$_ Timestamp $dt\n";
}
}
__DATA__
10/10/11 00:01:17 #984611
A 01 REPT:CELL 833 CP FAILURE, UNANSWERED TERMINATION
CDMA TRAFFIC CHANNEL CONFIRMATION FAILURE
TRAFFIC CHANNEL FAILURE REASON - ACQUIRE MOBILE FAILURE [2]
DCS 1 TG 1723 TM 374 SG 0 ANT 2
CARRIER 4, CHAN UNAVAIL FS-ECP ID 1, SYS ID 4681
DN 3168710330, MIN 3164094259, IMSI UNAVAIL
SN ###2ddff3 MEID Xa00000###629cc SCM ba
ALW CDMA, ASGN CDMA
CDM 1, CCU 2, CE 64, MLG 1/MLG_CDM 1
DCS 1/PSU 0/SM 3/BHS 6, ECP ID 1, SYS ID 4681
10/10/11 00:01:18 #984614
**01 REPT:CELL 983 CDM 1, CCU 1, CE 5, HEH
SUPPRESSED MSGS: 0
FT PL SECTOR 3 CARRIER 1 (1.9 GHz PCS)
FAILURE: OUT OF RANGE
PILOT LEVEL: MEASURED = 28.3 dBm EXPECTED = 33.8 dBm
SECONDARY UNIT: CDM 1, CBR 3
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/