Melb.pm meetings
Andrew Gray
agray at netconnect.com.au
Fri Jan 11 00:50:23 CST 2002
could someone kind please tell me how to sort a hash table
ie I have the following code fragment, sorry if it's not elegant, I'm not a
perl guru (yet!)
and I want to sort by ip number so the file gets written ordered.
open(LOG, "> deny.log") or die("Cant open deny.log for writing\n");
foreach $ip (keys %denylog)
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) =
localtime($denylog{$ip});
$year+=1900;
$human_time=$year."/".$mon."/".$mday." ".$hour."\.".$min;
if ( ($time-$denylog{$ip}) < $expire_time )
{
print LOG ($ip,":",$denylog{$ip},": ",$human_time,"\n");
} else {
# print "$ip was removed from deny list as it is too old\n";
$deny_list{$ip}=''; # remove it from the %deny_list as
it has aged out of list
}
}
close(LOG);
regards
Andrew Gray
Systems Administrator, NetConnect Communications
sysadmin at netconnect.com.au
More information about the Melbourne-pm
mailing list