my $lock = "/tmp/lock_foo"; if( ! -f $lock || time - (stat($lock))[9] > 600 ){ # do stuff open FILE '>', $lock; # optionally write info/details to it } #### use Cache::FileCache; my $cache = new Cache::FileCache( { namespace=>"TimeLocks" } ); my $key = "something_bad"; if( ! $cache->get($key) ){ # do stuff $cache->set( $key, time, "10 minutes" ); # note the value could just be '1', or any other true value. }