in reply to Breaking up a list of IP addresses for Snort

Are you sure the second if block (the test for $w =~ @fred[-1] is set up correctly? Looks like it'll execute regardless of the value of $g, in which case after $g is set to 0 in the if ($g == 20) block, $g is then incremented if the regexp match fails.

Also, are you sure about that regexp test? It's likely to only succeed if @fred[-1] is a pre-compiled re, which is doubtful given the other references to it. This is most likely why $g never tests equal to zero.