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

Re: Execute a for loop in many subdirectories

by dasgar (Priest)
on May 22, 2014 at 20:11 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1087131]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found