Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Execute a for loop in many subdirectories

by dasgar (Deacon)
on May 22, 2014 at 20:11 UTC ( #1087131=note: print w/ replies, xml ) Need Help??


in reply to Execute a for loop in many subdirectories

Don't know how many levels of subdirectories that you plan to search through, but you'll probably find File::Find (or File::Find::Rule, which I personally prefer to use) and the -X file test function to be useful.


Comment on Re: Execute a for loop in many subdirectories
Re^2: Execute a for loop in many subdirectories
by marlowvoltron (Novice) on May 22, 2014 at 20:34 UTC

    The depth is only 1, I don't need to go deeper than /antarctica/*

      The depth is only 1, I don't need to go deeper than /antarctica/*
      No need for File::Find then:
      my @dirs = grep -d, </antarctica/*>; for my $dir (@dirs) { chdir($dir) or die "Failed to chdir to $dir: $!"; execute_something(); }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2014-12-20 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls