use File::Basename;
my @file_list = qw(aa dd bb/aa cc dd kk/dd hh);
my @unique = do {
my %seen;
grep { $seen{$_} == 1 } grep { ! $seen{ basename( $_ ) }++ } @file_list;
};
Brian.
[0] http://perldoc.perl.org/File/Basename.html
The approach to remove duplicate items looks good and to get rid of files
having same names but different paths, may be you can split the the path
name items using a forward slash (/) and then try to grep if the last item
(file name) is already a existing file and if it is then skip it.
Cheers,
Pa
Hi,
I have a file_list array containing paths to files. I want to delete
duplicate elements from an array. Also i want to delete files with
conflicting names ie those elements with same name but different path
should also be deleted. I want this to be done with grep.
my @file_list= qw(aa dd bb/aa