Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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]
[erix]: I'm not going to read it so I could be mistaken but it reeks of useful idiocy
[shmem]: AngloZionist is not an antisemitic term.
[shmem]: erix: be assured that we all are horribly mistaken, always. What would we write tests for, if not for that fact?
[shmem]: and then, audiatur et altera pars.
[erix]: and what's the "Vineyard"? Don't tell me it's doing supernatural stuff too.
[shmem]: go figure. Might help to open views to other ways of perceiving reality. No, no supernatural stuff.
[shmem]: the "Vineyard" is a biblic term, also. But that's not the point.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-03-19 21:01 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (246 votes). Check out past polls.