Dirty Arrays and how to clean them up!

spamm_at_realconsultants.com
Date: 03/01/05


Date: 1 Mar 2005 11:28:29 -0800

I have this array with duplicate entries. Hundreds to be in fact.

For example:Array = 17177 9661 9661 9535 9533 9533 9533 9533 9533 9533
9533 9533 9533 9533 9533 9533 9533 9533 9532 9532 9532 9532 9531 9096
9096 9096 9095 9095 9095 8345 8345 8344 8344 8226 8226 8225 8225 8198
8198 8198 8198 8198 8198 8198 8198 8198 8198 8198 8198 8198 8198 8198
8198 8198 8198 8198 8198 8198 8198 8198 8198 8198..............

This is what i am doing. i am reading file1 that has these entries in
the file mutiple times. I am comparing it against file2. if i do not
find a match i write the record to file3 and then to an array. when i
read file1 again and compare it against file2 i check to see if the
recorrd has been written by rereading the array and looking for it.
if it finds the same entry in the array then read the next record do
not wirte to file3. if not then write the record to file3 and the
array.

i either want to only write once to the array per record or before i
check remove dupliactes.

here some code example:

while file1
  while file2
        if record1 != record2
           if record2 is not in array
              write to file3
              write to new record to array
              last
           else
               next
        else
            next

Here is another example that
  shows a poor example but you should get the idea. at least i
hope!!!!

@SORTED = ();
@CLEANED = ();
$X = 0;
$R = 0;
while ($R < 4)
      {
       while ($X <= 100)
             {
              $X++;
# print "I am in X\n";
# # i really do not want to write to the array if
# # it already exists in the array.
# # if array already has X then do not right to the
# # array.
              push @CHECKED, $X;
              @SORTED = sort {$a <=> $b} @CHECKED;
             }
# print "*********I am in R\n";
       $R++;
       $X = 0;
       next;
      }

print "Array = @SORTED\n";

foreach $Row (@SORTED)
      {
       $Hold = $Row;
       if ($Hold == $Row)
          {
           @CLEANED = shift @SORTED;
          }
          else
              {
               next;
              }
# # How do i remove duplicates from the array?
# # I know this is wrong but here is my delima!
      }

print "Array = @CLEANED\n";



Relevant Pages

  • Re: Formula logic explaination
    ... the formula boils down to ... Max finds the max number in the array. ... It finds duplicate entries ... > understanding it I would appreciate it. ...
    (microsoft.public.excel.programming)
  • Searching a list with repeat entries and creating a sum
    ... I have an array (single column) of part codes with an assciated number of ... Given that there may be duplicate entries in the ... part code listed only once in the column) and a second colum with the nummber ...
    (microsoft.public.excel.misc)
  • Re: extracting duplicating entries in a separate list
    ... >>> I have an array ... >>> I want to separate the duplicate entries and put in a list and put ... Prev by Date: ...
    (comp.lang.perl.misc)
  • extracting duplicating entries in a separate list
    ... I have an array ... I want to separate the duplicate entries and put in a list and put all ... Prev by Date: ...
    (comp.lang.perl.misc)
  • ld_info kernel service
    ... ldinfo's filename parameters contain garbage and there are lots of ... duplicate entries. ... then another entry appears in the array for the same lib, ... Im aware that ld_info will return ENOMEM till the array size is large ...
    (comp.unix.aix)