use strict; use warnings; use File::Find; # Search current dir unless dir(s) given as command line args @ARGV = qw(.) unless @ARGV; find( \&get_dirs_with_numbers, @ARGV ); sub get_dirs_with_numbers { return unless /^\d+$/; # your regex print $File::Find::name . "\n"; }