in reply to Selecting a particular record from groups of records
In Perl, the rule is: When in doubt, use a hash!
So, create an empty hash. Then read the data file, one record at a time: if its date/time is not already a key in the hash, store whatever values you need against this new key. If the date/time is already in the hash, compare the QC flags — if the new record has a smaller value, substitute the new record’s details for those currently stored against that date/time.
When all records have been read, output the hash contents, sorted by their date/time keys.
Hope that helps,
Athanasius <°(((>< contra mundum