You have warnings off; no wonder it runs without any messages :)
You're doing way too much work. If you simply make the ip address one number, it'll be a lot easier to sort on. I do that below by zero padding and joing the four numbers. You don't need to do anything with the time, since it's zero-padded, so you can sort it easily. For the date you can do the same: left-pad the numbers with zeros.
sub by_ip { my (%months, $i); $months{$_} = $i++ for qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct +Nov Dec); my $a_ip = join "", map { sprintf("%.3d", $_) } split /[.]/, $a->[ +0]; my $b_ip = join "", map { sprintf("%.3d", $_) } split /[.]/, $b->[ +0]; my @a_date = split '/', $a->[3]; my @b_date = split '/', $b->[3]; my $a_date = sprintf "%.2d-%.2d-%.4d", $a_date[0], $months{$a_date +[1]}, $a_date[2]; my $b_date = sprintf "%.2d-%.2d-%.4d", $b_date[0], $months{$b_date +[1]}, $b_date[2]; ($a_ip <=> $b_ip) || ($a_date <=> $b_date) || ($a->[4] <=> $b->[4] +); } sort by_ip @logentry;
I haven't tested it, since I do not know what your logfiles look like (post!).
Anyway, hope this helps.
In reply to (ar0n) Re: Hella sort
by ar0n
in thread Hella sort
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |