use strict; use File::Find; my @patch; find( sub { next if $File::Find::name =~ /xxx|yyy/; # somewhere in the full name next unless /\.ind$/i; # just considering the file itself push @patch, $File::Find::name; }, shift || '.' # starting directory from command line, or current dir );