sub next {
my $this = shift();
+
+ my $fh = new IO::File('+<' . $this->{file}) || return undef;
+ flock($fh, 2) || die "can't lock file";
+ my $n = <$fh>;
+ $fh->seek(0, 0);
+ sleep(int(rand(2)));
+ $fh->print($n+1, "\n");
+ $fh->close() or return undef;
+ return $n+0;
}
sub delete {
my $this = shift();
+
+ unlink $this->{file} or return 0;
+ return 1;
}