Re: remove line if field one is duplicate

2007-03-02 Thread Chas Owens
On 3/1/07, oryann9 <[EMAIL PROTECTED]> wrote: snip > perl -ne 'print unless $h{(split/:/)[0]}++' This is creating a anonymous hash, correct? snip No, the hash is named %h. The proper way to read $h{(split/:/)[0]}++ is "Increment the value whose key in %h is the first element of $_ when split

Re: remove line if field one is duplicate

2007-03-01 Thread John W. Krahn
oryann9 wrote: > --- Chas Owens <[EMAIL PROTECTED]> wrote: >> >>This should work >> >>perl -ne 'print unless $h{(split/:/)[0]}++' > > This is creating a anonymous hash, correct? No, incorrect. The hash is named %h. John -- Perl isn't a toolbox, but a small machine shop where you can special-o

Re: remove line if field one is duplicate

2007-03-01 Thread oryann9
--- Chris Charley <[EMAIL PROTECTED]> wrote: > > > This is creating a anonymous hash, correct? > > This is saying > print unless the first field has been seen before > > which is what he wants his code to do. > > $h is a good short notation - but using %seen > instead of %h may make it clearer

Re: remove line if field one is duplicate

2007-03-01 Thread oryann9
--- Chas Owens <[EMAIL PROTECTED]> wrote: > On 2/27/07, Keenan, Greg John (Greg)** CTR ** > <[EMAIL PROTECTED]> wrote: > > 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

Re: remove line if field one is duplicate

2007-02-28 Thread Rob Dixon
Keenan, Greg John (Greg)** CTR ** wrote: 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

Re: remove line if field one is duplicate

2007-02-28 Thread Chas Owens
On 2/27/07, Keenan, Greg John (Greg)** CTR ** <[EMAIL PROTECTED]> wrote: 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 firs

Re: remove line if field one is duplicate

2007-02-28 Thread Jeff Pang
-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