Derek Smith wrote: > > I am in need of some help! Here is the info you need for my samba mount > points. > > directories: ~emstat/win32/backup/012004155140/pc*, > ~emstat/win32/backup/01210415175/pc*, ~emstat/win32/pc* > files: under each of these subdirs, pc[#####], I have "training > 2001.eml" files ( NOTE THE SPACE ) that I need deleted! > so far this is what I have for my perl program > > /usr/bin/perl -w > use strict; > > # Open dirs and search for string > > $emdir="/home/emstat/win32/backup/012004155140"; > $emdir2="/home/emstat/win32/backup/012104151751"; > $emdir3= > opendir(DEREK, "$emdir") > || die "cannot open directory $!"; > opendir(SMITH, "$emdir2") > || die "cannot open directory $!"; > > while (defined ($readdir = DEREK)) > > > My questions are how can I have this search recursively down under all the > pc#### subdir names? > Can I create a scalar like "/home/emstat/win32/backup/012004155140/pc*" so > it will store all the pc subdirs? > Can I use reg exp such as a range of pc80[0-9] pc13[0-9] ?
Hi Derek. I think I would use File::Find twice: first to find all the /pc* directories and then to find all the *.eml files beneath them. The program below is untested but should be close to the mark, but it leaves the list of eml files in an array. (Best test it before you actually delete the files eh!). HTH, Rob use strict; use warnings; use File::Find; my @dirs = qw( /home/emstat/win32/backup/012004155140 /home/emstat/win32/backup/01210415175 /home/emstat/win32 ); my @pcdirs; find( sub { if (-d and /[^.]/) { push @files, $File::Find::name if /^pc/i; $File::Find::prune = 1; } }, @dirs); my @emls; find( sub { if (-f) { push @emls, $File::Find::name if /\.eml$/i; } }, @pcdirs); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>