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,
Parag



On Wed, Dec 15, 2010 at 8:27 AM, Sooraj S <soorajspadmanab...@gmail.com>wrote:

> 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 cc dd kk/dd hh);
> my %exist=();
> # This removes all the duplicate elements.
> my @unique = grep { ! $exist { $_ }++ } @file_list;
> #This removes conflicting files.
> #Please give me your answer
>
> My output should be => "cc hh"
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to