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.

The next thing that I see is you have declared the varaibles at the beginning of the block with "my" which is OK, like:

my @servicereport;

so now @serviceport is essentially an empty array ready for data to be assigned to it. But shortly after that you are using it to compare against:

Code

if($log[0] eq $servicereport[$i][0])

but as far as I can see $serviceport[$1][0] has never been assigned a value, it's an uninitialized value. If you had previoulsy populated @serviceport with data you need to import that data to the sub routine or define it within the sub routine (which you do later) before trying to do something with it. Maybe you can initialize @serviceport with some dummy data just to get things roliing:

Code

my @servicereport = ([0,0,0]);

but I am not sure if that will mess up the comparisons you are doing later. All that looping makes me think you should be using hashes instead of arrays. Build up a hash from the input file and use the hash to do the comparisons. Are you comparing all the lines of the input file against each other? -------------------------------------------------

thank you for the reply, ill look into using hashes instead as well as changing the use of <FILE>.

As for the question you asked, the sub routine is suposed to read in a line, compare this to what is in @servicereport(Nothing untill the first run through). If the data is not found, then it will be pushed into the array, if it is then a counter $servicereport[$i][2] should increase in value. The data is not needed after the sub routine is finnished, as it is printed to the screen.