#!/usr/local/bin/perl use strict; use warnings; my $kSkipSeconds = 3600; my %epochs; while () { chomp; my ($ip, $epoch) = split /,/; next if ! $epoch; $epochs{$ip} = $epoch; } my @ip_array = qw(1.1.1.1 1.1.1.3 1.1.1.2); my $now = 1320640620; # time() for my $ip (@ip_array) { if (exists $epochs{$ip} && $epochs{$ip} + $kSkipSeconds > $now) { print "Skipping $ip\n"; next } print "Time to update $ip\n"; $epochs{$ip} = $now; } print "------------ updated epochs -------------\n"; print "$_,$epochs{$_}\n" for sort keys %epochs; __DATA__ 1.1.1.1,1320639902 1.1.1.3,1320640560 1.1.1.2,1320600900 #### Skipping 1.1.1.1 Skipping 1.1.1.3 Time to update 1.1.1.2 ------------ updated epochs ------------- 1.1.1.1,1320639902 1.1.1.2,1320640620 1.1.1.3,1320640560