my @patches = grep {/xxx|yyy/} ; # Above gives the full path to the patches # If you just want the filename, not the full path, use this: #my @patches = map { (split /\//)[-1] } grep {/xxx|yyy/} ;