I have the below shown directory structure.
- I would like to get just the project names in my @project.
@project=('project1','project2')
; - I would like to exclude
OLD
directory and its sub directories in@project
- I would like to get latest file in the subdirectories for all projects in
@project
. i.e., forproject1
, latest file is in sub directory2014
, which isfoobar__2014_0916_248.txt
How can I frame a rule to achieve this?
use strict;
use File::Find::Rule;
use Data::Dump;
my $output = "/abc/def/ghi";
my @exclude_dirs = qw(OLD);
my @projects = File::Find::Rule->directory->in("$output");
dd \@projects;
My Dir Structure:
.
├── project1
│ ├── 2013
| ├── file1_project1.txt
│ └── 2014
| ├── foobar__2014_0912_255.txt
| ├── foobar__2014_0916_248.txt
├── project2
│ ├── 2013
| ├── file1_project2.txt
│ └── 2014
| ├── foobarbaz__2014_0912_255.txt
| ├── foobarbaz__2014_0916_248.txt
└── OLD
└── foo.txt
As ikegami suggested, just do this in two steps.
The following does this using
Path::Class
andPath::Class::Rule
Outputs: