in reply to Re^2: Printing files that has two different extensions in a given directory
in thread Printing all the files that have both ".rtf" and ".ftp" by searching recursively in a given directory
use strict; use warnings; use File::Find::Rule qw( ); use File::Basename qw( basename ); my %files; for ( File::Find::Rule ->file() ->name('*.rtf', '*.ftp') ->in('.') ) { my ($name, $ext) = basename($_) =~ /^(.*)\.(.*)\z/; ++$files{$name}{$ext}; } for my $name (%files) { print("$name\n") if $files{$name}{rtf} && $files{$name}{ftp}; }
Update: Tested. Fixed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Printing files that has two different extensions in a given directory
by JavaFan (Canon) on Apr 12, 2011 at 21:20 UTC | |
by ikegami (Patriarch) on Apr 12, 2011 at 21:39 UTC | |
by JavaFan (Canon) on Apr 12, 2011 at 22:12 UTC | |
by ikegami (Patriarch) on Apr 12, 2011 at 22:29 UTC | |
by JavaFan (Canon) on Apr 12, 2011 at 22:45 UTC | |
|
Re^4: Printing files that has two different extensions in a given directory
by Anonymous Monk on Apr 12, 2011 at 21:45 UTC | |
by ikegami (Patriarch) on Apr 12, 2011 at 22:40 UTC |