
spiitfire
Novice
Apr 15, 2006, 8:23 AM
Post #1 of 4
(2064 views)
|
|
Array Element Comparison Error - Uninitialized value of string eq error
|
Can't Post
|
|
Hello All, I was hoping I wouldn't have any more problems with my code but have stumbled on an error that i have spent a few hours trying to solve. Use of Uninitialized value of string eq error at firewall.pl line 104, <FILE> line***(all the lines it reads in). Testing each section individualy asides from the check seems to show promise, although the code definately could be cleaned up and made more efficient but ill get to that once it is running. The error I can see seems to be when comparing the array elements values against each other. I'm using 'eq' to check this and would assume that this would be correct to use, but am generating the error for every single line scanned in during run time. This sub is reading in a file and processing this into an array line by line, then tranfering the appropriate fields into another array. Checking the fields to see if they have been seen before, if so increasing the count for this otherwise creating a new element line. This is to cycle over the whole file untill completed then results outputted to the screen. sub processlog { my @log; my @servicereport; my @temp; my $line; my $count = 0; my $secondcount=1; my $second=0; my $i = 0; open (FILE, "fwlog") or die "\nError unable to open fwlog!"; while(<FILE>) { next unless /;log;/ ; chomp; $line = <FILE>; @temp = split(/;+/, $line); unless ($line =~ /EDT/) { #strange, needed as include non ;log; files:| $log[0] = $temp[8]; $log[1] = $temp[11]; $log[2] = "1"; $count++; } for($i=0;$i<=$secondcount;$i++) { if($log[0] eq $servicereport[$i][0]) { if($log[1] eq $servicereport[$i][1]) { $servicereport[$i][2]++; } } else { push @servicereport, [ @log]; $secondcount++; } } } for($i=0;$i<$secondcount;$i++) { $servicereport[$i][3] = (($servicereport[$i][2] / $count)*100); $servicereport[$i][3] = sprintf ("%.2f", $servicereport[$i][3]); } print "\nService Usage: Top number of total\n"; print "================================================\n"; for($i=0;$i<$secondcount;$i++) { print "$servicereport[0][0]($servicereport[0][1])"; print "\t\t\t$servicereport[0][2] $servicereport[0][3]%\n"; } } Any hints into the right direction would be greatly appreciated on this as I am absolutely stumped. Regards, Spiitfire
|