I need to read the name/value pairs from *a single selected line* from an unsorted flatfile whose fields names may vary and some may be empty. The line is selected by the ID field. The unique field value is always the ID field. Many other fields are the same, with a fiew oddball name/value pairs not shared in other lines.

The fields go by $item,$value pairs split with a colon, with a pipe separator in between. Example:

I'm having a problem selecting the line to read by ID. I need to isolate that line before getting the $item, $value pairs, but I can't select the line to view the value of $item(id) for a match to my query without some kind of regex or split.

You can split every line on the '|'. This gives you a list of strings of the form NAME:VALUE. You now turn this list into a hash. Then you can access the 'id' field of this hash. If this is the id you are looking for, you've found your line.

As an alternative to building the hash, you can also loop through the list until you find a string which has the form 'id:NNNN'.

I'm having a problem selecting the line to read by ID. I need to isolate that line before getting the $item, $value pairs, but I can't select the line to view the value of $item(id) for a match to my query without some kind of regex or split.