
BillKSmith
Veteran
Dec 3, 2010, 8:33 AM
Post #2 of 2
(273 views)
|
|
Re: [xsustek] deleting duplicates in two dimensional array
[In reply to]
|
Can't Post
|
|
Strictly speaking, you cannot have a two dimensional array in perl. We simulate it very well with a list of lists. That is, we have list which contains references to other lists, each of which contains the data for one row. There are two ways you can have "duplicate rows". In one case you have two or more duplicate references which refer to the same list of row data. In the other case, you have references which refer to different lists which contain identical data. The second case is much more common. You really have two problems. Find the duplicate and remove it. If you are sure that you have case 1, the find part can be much easier and faster, but an algorithm which does the find for case 2 will work for case 1. In either case, remove the reference with splice (refer perldoc -f splice). I recommend using a CPAN module such as Array::Compare or List::Compare to do the actual compares. Good Luck, Bill
|