use strict;
my %CELL;
my %CELL_TYPE_COUNT;
while (my $line = <DATA>) {
if ($line =~ /CELL\s+(\d+)\s+(.+?),.+?HEH/) { # take CELL number into
$1 and the information after the number (and before the first comma)
into $2
$CELL{$1}{$2}++;
$CELL_TYPE_COUNT{$2}++;
}
}
# header
print "CELL,".join(",",sort keys %CELL_TYPE_COUNT)."\n";
# body
foreach my $cellNo (sort keys %CELL) { # you can use map function, but
it never sits well on my brain
print "$cellNo";
foreach my $info (sort keys %CELL_TYPE_COUNT) {
if (exists $CELL{$cellNo}{$info}) {
print ", $CELL{$cellNo}{$info}";
}
else {
print ", 0";
}
}
print "\n";
}
__DATA__
00 REPT:CELL 20 CDM 1, CRC, HEH
SUPPRESSED MSGS: 0
ERROR TYPE: ONEBTS MODULAR CELL ERROR
SET: DS1-MLG ASSOCIATION CHANGE
MLG 1 DS1 1,2
00 REPT:CELL 20 CDM 1, CRC, HEH
SUPPRESSED MSGS: 0
ERROR TYPE: ONEBTS MODULAR CELL ERROR
SET: DS1-MLG ASSOCIATION CHANGE
MLG 1 DS1 1,2
00 REPT:CELL 21 CDM 2, CRC, HEH <- my own test data
CELL,CDM 1,CDM 2
20, 2, 0
21, 0, 1
>
> Let me know if it's correct.
>
> On Sat, Oct 15, 2011 at 11:55 AM, Chris Stinemetz
> <[email protected]> wrote:
>> On Sat, Oct 15, 2011 at 1:12 PM, Leo Susanto <[email protected]> wrote:
>>> Chris, You need to let us know what do you want the script to do,
>>> believe me, writing the script is the easy part.
>>>
>>
>>
>> Okay I will try to clarify. For right now there is only one type of
>> line that I am interested in from the input file.
>>
>> I will try to break this down sequentually in how I am trying to
>> construct this program:
>>
>> Read the input file and only keep lines that have a line with the
>> text pattern: HEH
>>
>> Now the tricky part I am having some difficulty with:
>>
>> sort and count each occurence of different types of HEH grouped by the
>> CELL number.
>>
>> And finally datafill the format table with the results.
>>
>> So for example:
>>
>> 00 REPT:CELL 20 CDM 1, CRC, HEH
>> SUPPRESSED MSGS: 0
>> ERROR TYPE: ONEBTS MODULAR CELL ERROR
>> SET: DS1-MLG ASSOCIATION CHANGE
>> MLG 1 DS1 1,2
>>
>> 00 REPT:CELL 20 CDM 1, CRC, HEH
>> SUPPRESSED MSGS: 0
>> ERROR TYPE: ONEBTS MODULAR CELL ERROR
>> SET: DS1-MLG ASSOCIATION CHANGE
>> MLG 1 DS1 1,2
>>
>> Would output something like:
>>
>> Cell CBR CDM1 CDM2 CDM3 TFU1 TFU2 CCU EVM
>> TXAMP CTRM
>> --------- -------- -------- --------- ---------
>> -------- --------- -------- -------- --------
>> --------
>> 20 2
>>
>>
>> I hope this helps clarify.
>>
>> Thanks for all the help,
>>
>> Chris
>>
>
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/