Ask a Question related to PERL Beginners, Design and Development.
-
DBSMITH@OhioHealth.com #1
another directory search, yet many subdirs
People of the Perl,
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] ?
please help!
thank you,
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
DBSMITH@OhioHealth.com Guest
-
Active Directory Search fails ("The directory service is unavailab
Hi all, I'm having one of those nerve wrecking errors, when trying to perform a simple search in an Active Directory. The objective of the code... -
Google groups email spider,Auction software, Directory PPC search engine software, email spiders - 4
Free download full version , all products from Mewsoft dot com http://netauction8.url4life.com/ Groupawy --------------- Google Groups Email... -
Free Health, Fitness, Leisure Directory - are you on it? do you need it? Get listed or search it for free.
List your health business on the health directory at no cost. Browse and find a practitioner, therapist, gym, spa etc... 1/4 Million hits in 7... -
Directory Search
I need help and guidence towards learning material to build a directory search utility into my asp.net page. I have a Directory called "Trusses"... -
how to reference assemblies from web.configs in subdirs?
Hello, I was wondering how I can reference assemblies from web.config files residing in subdirectories without having to create a new project for... -
DBSMITH@OhioHealth.com #2
RE: another directory search, yet many subdirs
David,
under each of these suddirs, I need all the eml files deleted but there
are thousands of them and the actual file name is "training 2001.eml"
so my questions still remain,
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] ?
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145
"Wagner, David --- Senior Programmer Analyst --- WGO"
<fedex.com>
02/16/2004 06:02 PM
To: <com>, "Perl Beginners" <org>
cc:
Subject: RE: another directory search, yet many subdirs
com wrote:
It si not clear in my mind the setup you have. The
process you want to use is probably File::Find which comes as standard portion of all Perl installs. If I could picture
the setup in my mind, I could give you a better picture of what to do.
Sorry.
Wags ;)
************************************************** ********
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
************************************************** **************
DBSMITH@OhioHealth.com Guest
-
Matt #3
RE: another directory search, yet many subdirs
<snip>
under each of these suddirs, I need all the eml files deleted but there
are thousands of them and the actual file name is "training 2001.eml"
so my questions still remain,
Can I have this search recursively down under all the pc#### subdir
names?
</snip>
File::Find will do what you need. Google can help you find some good
examples.
Matt Guest
-
Rob #4
Re: another directory search, yet many subdirs
Derek Smith wrote:
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);
Rob Guest



Reply With Quote

