
RockE70
Novice
Oct 18, 2013, 4:31 AM
Post #1 of 9
(37376 views)
|
Using file find to search directories problem
|
Can't Post
|
|
Hi Gurus Could someone point me in the right direction with what I'm trying to do here. I want to list all directories from a source directory but only drill down to a directory starting with I, D or P and having only 8 characters in the directory name. The last script in this code (4 variations in total) which I've commented out works but shows all directories from the source directory
use strict; use warnings; use File::Find; use Fcntl; #*****************Global Variables********************** our $wellpath = 'N:\\repos\\open\\Wells\\Regulated'; our $surveypath = 'N:\\repos\\open\\Surveys\\Regulated'; #*******************************************************
#find(sub{print "$_\n";},"$wellpath");
#find(\&dir_names, "$wellpath"); # sub dir_names { # if(-f $File::Find::dir,'/') { # if (-d $wellpath =~ qr{^([IPD]\d{8})$}) { # print "$File::Find::dir\n" # } # } # } find(\&dir_names, "$wellpath"); sub dir_names { if(-f $File::Find::dir,'/' =~ qr{^([IPD]\d{8})$}) { print "$File::Find::dir\n" } } #find(\&dir_names, "$wellpath"); # sub dir_names { # print "$File::Find::dir\n" if(-f #$File::Find::dir,'/'); # } #} Thanks
|