You're still very unclear, but I'm pretty sure you want the following:
For each file matching *.rtf, print its name if that directory also has similarly named file with the .ftp extension.
my @dirs = File::Find::Rule ->directory() ->in('.'); for my $dir (@dirs) { my @rtfs = File::Find::Rule ->maxdepth(1) ->file() ->in($dir); for my $rtf (@rtfs) { ( my $ftp = $rtf ) =~ s/\.rtf\z/.ftp/; if (-e $ftp) { print("$rtf\n"); } } }
Update: Condensed:
my @files = File::Find::Rule ->file() ->name('*.rtf') ->exec(sub{ my $rtf = $_; ( my $ftp = $rtf ) =~ s/\.rtf\z/.ftp/; -e $ftp; }) ->in('.');
In reply to Re: Printing files that has two different extensions in a given directory
by ikegami
in thread Printing all the files that have both ".rtf" and ".ftp" by searching recursively in a given directory
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |