#!/usr/bin/perl -w

use POSIX;

my @tmp_files;
my $creating = 0;
my $count = 20000;

while ($count > 0) {

    if (rand(20) < 1.0) {
        $creating = not $creating;
	# tweak the fractional seconds to adjust the delay
	select(undef, undef, undef, 1.0);
    }

    if ($creating) {
	my $name;
	do {
	    $name = tmpnam(); # . ".ods";
	} until sysopen(FH, "$name", O_RDWR|O_CREAT|O_EXCL, 0666);
	close FH;
#	print "created $name\n";
	push @tmp_files, $name;
    } elsif (@tmp_files) {
	my $name = pop (@tmp_files);
#	print "removing $name\n";
	unlink ($name);
    }

#    $count--; # or run endlessly ?
}
