#!d:\perl\bin\perl.exe $pth = "\\\\127.0.0.1\\bex"; opendir(Directory, $pth) or die "Cannot Open Directory"; @contents = grep { m!^[Bb].+\.txt$! #assuming .txt ending and -M "$path\\$_" > 1 } readdir(Directory); closedir(Directory);