Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How do I recursively process files through directories

by xbmy (Friar)
on Dec 04, 2009 at 19:35 UTC ( [id://811147]=note: print w/replies, xml ) Need Help??


in reply to How do I recursively process files through directories

Another way to recurse a directory and print the files you want to get,the following is the code.
use strict; use warnings; sub ransack { #dir,\@files my $dir=shift; my $files=shift; my @array=glob("$dir\\*"); foreach my $item (@array) { if(-d $item) { ransack($item,$files); } else { $files->[@$files]=$item; } } } my ($array, @array); ransack("path of your directory",\@array); #path of your directory foreach $array (@array) { if ($array=~/txt|csv/) { #match your file format print ("$array\n"); } }
Enjoy!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://811147]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2025-07-17 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.