-----Original Message----- >From: "Keenan, Greg John (Greg)** CTR **" <[EMAIL PROTECTED]> >Sent: Feb 28, 2007 12:39 PM >To: beginners@perl.org >Subject: remove line if field one is duplicate > >Hi, > >I have to combine several Unix password files and remove any duplicate >accounts - putting this into LDAP. > >I have the following code that will remove any duplicate whole lines but >I need to remove lines only if the first field of the password file is a >duplicate.
Hello, Just give a simple test and I think this may work: $ perl -Mstrict -e ' > my %hash; open HD,"/etc/passwd" or die $!; > my @uniq_users = map { $_->[1] } grep { ++$hash{$_->[0]} < 2 } map { > [(split/:/)[0],$_] } <HD>; > print @uniq_users ' -- Jeff Pang EMAIL: pangj<at>earthlink.net AIM: jeffpang -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/