Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: How do I recursively process files through directories

by xbmy (Friar)
on Dec 04, 2009 at 19:35 UTC ( #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"); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811147]
[Corion]: marto: Oh, I'm jealous. I'm going to see DM in Frankfurt, but it's a stadium full of people, so, rather a big thing where you mostly get to see the band on screens ;)
[marto]: yes, the last time I saw them was in Berlin a few years ago, at the old Olympic stadium
[marto]: After Sunday I don't think I'll go see them again :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-03-24 11:34 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (301 votes). Check out past polls.