Hello, I am trying to create a Perl script that will scan a file using regex to match certain patterns and return uniq names and the total count of each match.
With the sample input data (on the far bottom) the return value should be CELL 20 in Column 1 with 2 Counts of CDM HEH in the third column. So far I have two scripts. I am using one to allocate the subroutines for each type of regex match, and the other script will call the routines and populate the table that I am trying to create. I think once I figure out how to handle the first subrountine I should be able to get the rest, but I can't seem to wrap my head around it. Thanks in advance, Chris My scripts thus far: heh.pl #!/usr/bin/perl use warnings; use strict; requuire "heh.lib"; # my $filepath = sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d%H",localtime)); my $filepath = ("/tmp/110923.APX"); # for testing my $runTime = sprintf("/home/cstinemetz/programs/%s.txt",strftime("%Y-%m-%d-%H:%M",localtime)); my $fileDate = strftime("%y%m%d%H%",localtime); open my $fh, '<', $filepath or die "ERROR opening $filepath: $!"; open my $out, '>', $runTime or die "ERROR opening $runTime: $!"; while(<$fh>) { if (/,HEH/); } print $out form " ^>>>>>> HR 17-21 HEH Report @<<<<<<<<<<<<<<<<<<", " Cell CBR CDM1 CDM2 CDM3 TFU1 TFU2 CCU EVM TXAMP CTRM ", "--------- -------- -------- --------- --------- -------- --------- -------- -------- -------- --------"; heh_lib.pl #!/usr/bin/perl use warnings; use strict; sub getCell { my $str = "REPT:CELL, HEH"; } input file: 10/13/11 00:00:57 #023342 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 00 00 00 00 00 00 00 03 00 00 00 00 00 05 05 05 05 05 05 10/13/11 00:00:58 #023345 00 REPT:CELL 20 CDM 1, CRC, HEH SUPPRESSED MSGS: 0 ERROR TYPE: ONEBTS MODULAR CELL ERROR SET: MLG BANDWIDTH CHANGE MLG 1 BANDWIDTH = 3072 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10/13/11 00:00:59 #023346 00 REPT: EVDO: RNC 20 CP FAILURE SUMMARY CONNECTION RELEASE MAI OR FDI NOT RECEIVED, ERROR CODE 40000 BTS VAR, BAND CLASS 1, CHANNEL 1175, SECTOR VAR TOTAL MESSAGES FOR 30-MINUTE INTERVAL: 9 SERVICE NODE 19, TP 310 IMSI VAR, HW TYPE 00ffff, HW ID VAR UATI VAR PERCEIVED SEVERITY: WARN 2011-10-13 00:01:41 REPORT #000001 FINAL -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/