Re: remove duplicate elements from an array

2010-12-18 Thread David Christensen
I wrote: You should buy the Perl Cookbook: http://oreilly.com/catalog/9781565922433 Jeff Peng wrote: does the cookbook have a new edition? I remember I have read it several years ago. 2nd edition is the latest, AFAIK. Oops! Bad URL above. Here's the latest: http://oreilly.com/ca

Re: remove duplicate elements from an array

2010-12-18 Thread Jeff Peng
Original-Nachricht > Datum: Fri, 17 Dec 2010 20:07:33 -0800 > Von: David Christensen > > You should buy the Perl Cookbook: > > http://oreilly.com/catalog/9781565922433 > > does the cookbook have a new edition? I remember I have read it several years ago. Jeff. -- Ne

Re: remove duplicate elements from an array

2010-12-18 Thread Rob Dixon
On 18/12/2010 19:21, Arun G Nair wrote: Sooraj S wrote: I have an array file_list which contains absolute/relative paths of files. I want to remove duplicate elements and elements whose filenames(not the path) are same. How can i do this using grep and hash? My code === my @file_list= q

Re: remove duplicate elements from an array

2010-12-18 Thread Arun G Nair
Try: [~]$ perl -MFile::Basename -le '@file_list = qw(aaa ddd bbb/aaa ccc ddd kkk/ddd hhh); $,="," ; print grep { $h{$_} == 1 } grep { ++$h{$_} } map { basename($_) } @file_list;' ccc,hhh [~]$ perl -le '@file_list = qw(aaa ddd bbb/aaa ccc ddd kkk/ddd hhh); $,="," ; print grep { $h{$_} == 1 } grep

Re: remove duplicate elements from an array

2010-12-18 Thread Sooraj S
On Dec 18, 9:07 am, dpchr...@holgerdanske.com (David Christensen) wrote: > Sooraj S wrote: > >  > I have an array file_list which contains absolute/relative paths of >  > files. I want to remove duplicate elements and elements whose >  > filenames(not the path) are same. How can i do this using gre

Re: remove duplicate elements from an array

2010-12-17 Thread David Christensen
Sooraj S wrote: > I have an array file_list which contains absolute/relative paths of > files. I want to remove duplicate elements and elements whose > filenames(not the path) are same. How can i do this using grep and > hash? You should buy the Perl Cookbook: http://oreilly.com/catalog/9781

remove duplicate elements from an array

2010-12-17 Thread Sooraj S
Hi, I have an array file_list which contains absolute/relative paths of files. I want to remove duplicate elements and elements whose filenames(not the path) are same. How can i do this using grep and hash? My code === my @file_list= qw(aaa ddd bbb/aaa ccc ddd kkk/ddd hhh); my %exist=(); #To