http://www.perlmonks.org?node_id=617478


in reply to How to implement something similar to Unix's find syntax?

I am just trying to create a funny code. It accepts two arguments directory to search and filename
It will work on Unix. you can make it work on Windows by reversing the slash.
Just try perl <script name> <dir name> <file name>
my ($mydir, $word) = (@ARGV); opendir(DIR, "$mydir") || warn "can't opendir : $!"; @dots = grep { /\w/ } readdir(DIR); closedir DIR; foreach $dir_tree(@dots) { #print "$dir_tree\n"; opendir(DIR, "$dir_tree"); @dots1 = grep { /\w/ } readdir(DIR); foreach $dir_tree1(@dots1) { push @dots, "$dir_tree/$dir_tree1"; my $name = "$dir_tree/$dir_tree1"; print "$dir_tree/$dir_tree1\n" if ($name =~ m/\Q$word\ +E/is); } closedir DIR; }