Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recurse directories

Status
Not open for further replies.

zwark

ISP
Joined
Sep 28, 2001
Messages
3
Location
US
Anyone has a function in Perl that recurse subdirectories?
 
Check out the File::Find module.


regards
C
 
See faq219-969 for an example of how to use File::Find. Cheers, NEIL
 
Try this Subroutine if you'd like. It's something I use currently to check for files of a certain age (less than 1 day old) and create an HTML page from these files. I'm sure it's not the cleanest code, but it works for my purposes.

[tt]sub g
{
foreach (glob "$_[0]/*")
{
# recurse into subdirectories
-d && g($_) unless -l;
# if file ending in desired extension
if (-f && /\.pdf$/i)
{
# check file for age. If less than 1 day old,
# create HTML page of directory.
if ((-M) < 1.02)
{
my $file = $_;
writehtml(&quot;$file&quot;,&quot;$topdir&quot;); # start HTML creation subroutine
return;
}
}
}
}
[/tt]

Hope this helps some!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top