>From looking at the regex > if ($line =~ > /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){
against the data > 10/17/11 18:25:20 #578030 > > 25 REPT:CELL 221 CDM 2, CRC, HEH > SUPPRESSED MSGS: 0 > ERROR TYPE: ONEBTS MODULAR CELL ERROR > SET: MLG BANDWIDTH CHANGE > MLG 1 BANDWIDTH = 1536 I would assume $1 and $2 wouldn't match to anything plus $5 doesn't exist. Could you please let us know which part of the data you want to extract? Fill in the blanks $1= $2= $3= $4= $5= On Mon, Oct 17, 2011 at 8:32 PM, Chris Stinemetz <chrisstinem...@gmail.com> wrote: > Hello, > > I am getting the following error when I am trying to use regex to > match a pattern and then access the memory variables: > > Any insight as to what I am doing wrong is greatly appreciated. > > Thank you, > > Chris > > Use of uninitialized value $1 in hash element at ./heh.pl line 22, > <$fh> line 1211. > Use of uninitialized value $4 in hash element at ./heh.pl line 22, > <$fh> line 1211. > Use of uninitialized value $5 in hash element at ./heh.pl line 22, > <$fh> line 1211. > > An example of what I am trying to match is: > > 10/17/11 18:25:20 #578030 > > 25 REPT:CELL 221 CDM 2, CRC, HEH > SUPPRESSED MSGS: 0 > ERROR TYPE: ONEBTS MODULAR CELL ERROR > SET: MLG BANDWIDTH CHANGE > MLG 1 BANDWIDTH = 1536 > > 00 00 06 00 00 00 00 00 > 00 00 00 00 00 00 00 00 > 00 00 00 00 > > > > 10/17/11 18:25:20 #578031 > > 25 REPT:CELL 221 CDM 2, 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 01 00 05 05 > > > My program: > > #!/usr/bin/perl > > use warnings; > use strict; > use POSIX; > > # 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: $!"; > > my %date; > my %cell; > my %heh_type_count; > while (my $line = <$fh>) { > if ($line =~ > /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){ > $cell{$1}{$4}{$5}++; > $heh_type_count{$5}++; > } > } > > # header > print "HOUR\t"."CELL\t".join("\t",sort keys %heh_type_count)."\n"; > # body > foreach my $cellNo (sort {$a <=> $b} keys %cell) { > print "$cellNo"; > foreach my $heh_hits (sort keys %heh_type_count) { > if (exists $cell{$cellNo}{$heh_hits}) { > print "\t $cell{$cellNo}{$heh_hits}"; > } > else { > print "\t 0"; > } > } > print "\n"; > } > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/