Re: Array with unique elements only

2004-05-21 Thread Mark Martin
Thanks Ramprasad - that works. At 17:29 20/05/2004 +0530, Ramprasad A Padmanabhan wrote: Wow, unique items is surely an FAQ. But here you dont need to filter the array, just see the answer inline On Thu, 2004-05-20 at 17:07, Mark Martin wrote: > Hi, > I'm moving database data from table to table an

Re: Array with unique elements only

2004-05-20 Thread Rob Dixon
Ramprasad A Padmanabhan wrote: > > Wow, > unique items is surely an FAQ. > But here you dont need to filter the array, just see the answer inline > > On Thu, 2004-05-20 at 17:07, Mark Martin wrote: > > Hi, > > I'm moving database data from table to table and want to make sure I'm > > getting only u

Re: Array with unique elements only

2004-05-20 Thread Jeff 'japhy' Pinyan
On May 20, Jeff 'japhy' Pinyan said: > my (%count, %unique); > > while (my @row = $sth->fetchrow) { >my $field = $row[0]; >if ($count{$field}++) { delete $unique{$field} } >else { $unique{$field} = [ @row ] }; # or 1, or whatever you want > } > >Here, every time a row is seen, its

Re: Array with unique elements only

2004-05-20 Thread Jeff 'japhy' Pinyan
On May 20, Mark Martin said: >I'm moving database data from table to table and want to make sure I'm >getting only unique records. This is similar to a topic that came up two days ago. >Only want unique $field1 and was looking at the cookbook code, but for that >I have to populate a hash and the

Re: Array with unique elements only

2004-05-20 Thread Ramprasad A Padmanabhan
Wow, unique items is surely an FAQ. But here you dont need to filter the array, just see the answer inline On Thu, 2004-05-20 at 17:07, Mark Martin wrote: > Hi, > I'm moving database data from table to table and want to make sure I'm > getting only unique records. > > Only want unique $field1 a

Array with unique elements only

2004-05-20 Thread Mark Martin
Hi, I'm moving database data from table to table and want to make sure I'm getting only unique records. Only want unique $field1 and was looking at the cookbook code, but for that I have to populate a hash and then re-inspect through before inserting uniques, something like : %ucnt = (); while