Thanks for the quick reply. The results usually aren't big. Sorting in mysql query will not work since it will only sort for that one record not the final output. What I have done in the past is save all the resuls to a file then run another script which will sort based on the IP address in the results. Shown below. What I am hoping to do is eliminate having to run the second script and do the sorting and query on all one script(Also learn in the process). I am pretty new to Perl so I am still trying to work myself through some of the examples I find online. Here is the script which I use to sort the results.
my @lines this is array of the file being read in)
my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1] ||
$a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] ||
$a->[4] <=> $b->[4]} map {
[$_, split(/\./, (split /\s+/, $_)[1])]} @lines;
print "$_\n" for @sorted;