in reply to Extracting records with unique ID

I'd suggest you unpack all fields in each record. Then depending on the type of record (CX4, for example) you populate (for example) $hash{$USERNUM}{EXTK} = $EXTK;

When you've finished processing the file, you can loop through all keys of the hash, and display the hash values however you wish.

I wouldn't rely on a simple match of the record-type because you could conceivably have CX4 as a value in a record of type CT2