Hi,

Try this...it works for me to search for any type of file.....

Need to call a recursive directory listing to search for all sub 
directory within a directory.
&listdir ($dir); # $dir the directory you want to search
#subroutine starts here

Sub listdir {
my ($direc)=@_;
$direc=*the directory you want to call from where to start the search***
if (opendir (DIR,$direc)){
@files = readdir(DIR);
closedir (DIR);
$count=0;
foreach $file (@files)
{

if (($file ne ".") and ($file ne ".."))
{

if ($file !~ /\./) {

&listdir ("$direc\\$file");}
else 
{


if (($file =~ /\.$types\Z/i) )
{

$count =$count+1;

print "$file \n";
}
}
}

}
}
}

else 
{return;}
}

Regards
Samir

-----Original Message-----
From: perl 
Sent: Monday, November 06, 2000 7:13 AM
To: perl-win32-admin
Cc: perl
Subject: FW: Loop through directory looking for text files


Hi

I do something similar in a shell script on linux - how could I do this 
in
.pl on NT:

loop through a directory looking for *.txt files - then this 
adddomains.exe
opens each text file and runs about 10 commands. (If i run 
adddomains.exe
filename.txt it works fine - I just want to loop the directory for text
files.

============================
for DIR *.txt
do
        adddomains.exe $DIR
done
============================

Sorry normally shell scripts on Linux.

Tony


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin


Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.
 
E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to