in reply to funny results: unexpected order reversal

Can't you just do:
# add the $cnn to an array to keep order push @good, $cnn if $lines{$cnn} ne '1'; # add a key to a hash so you don't have to # loop through the array each time $lines{$cnn} = 1;

Then you don't have any dupes, you just have the cc numbers.
I am 100% what you asking because it looks like you have much more going on then was presented. If I am way off please help clue me in.