# get last known position of EOF if (open(SEEK, "; chomp $seek; close SEEK; } else { # no EOF recorded, find it warn "Failed to read seek: $!\nCreating\n"; open(LOG, "<$log") or die "Can't read $log: $!"; # always a good idea to check the result of your open! seek(LOG, 0, 2); # jump to the EOF $seek = tell(LOG); close LOG; &write_seek($seek); exit; } open(LOG, "<$log") or die "Can't read $log: $!"; seek(LOG, $seek, 0); # jump to the last EOF while () { $id = (split / /)[2]; $login_id{$id}++; } $seek = tell(LOG); &write_seek($seek); close LOG; sub write_seek { my $seek = shift; open(SEEK, ">seek") or die "Can't write to seek: $!"; print SEEK $seek; close SEEK; }