for ($i=0; defined($i); $i++){ unless (-e "./tempads/$i.dat" || ){ open (FILE, ">./tempads/$i.dat"); print FILE "stuff"; close FILE; } }