#!/usr/local/bin/perl -w use strict; use File::Find; my $bench_file = 'bench.txt'; my @new_files; find( { follow => 1, no_chdir => 1, wanted => \&callback }, '/'); sub callback { if (! /\.$/) { # ignore unwanted . or .. if ( ! `grep '$_' $bench_file` ) { push @new_files, $_; # remember this file } } } # append unseen filenames to bench.txt file open BENCH, ">>bench.txt" or die "Can not append to bench.txt"; print BENCH "$_\n" foreach (@new_files); close BENCH;