foreach my $file (grep { !-e } @files) # The grep returns all the elements of the array # for which the sub ( { !-e } ) returns true, which it # will only if $_ (the array element being tested) does not # exist. If you want it to exist and be a # regular file (as opposed to a directory, FIFO, etc.) # use -f. { local *FH; # To make sure we don't clobber FH. open FH, ">>$file"; # In case the file got created # in the meantime, we use the append operator to avoid # clobbering data. close FH; # And then we close it. }