use File::Find; my @java_file; find(sub { push @java_file, $File::Find::name if /\.java$/i }, "/desired/path");