I have a file generated by a compiler that has warning messages in the following format:
--a couple of lines of text--
Warning-[code1] <some description>
<some path>, error code
--3-4 lines of cryptic messages--
Warning-[code2] <some description>
<some path>, error code
--3-4 lines of cryptic messages--
Warning-[code1] <some description>
<some path>, error code
--3-4 lines of cryptic messages--
etc...
I have a script that will read in the codes, but the problem is some codes are repeated like 10 times and i want to read them once i.e uniquify them. I was thinking of reading the entire file in an array and then uniquify it based on the codes? But is it possible? before i go ahead and start coding.
Really appreciate your input/help/thoughts 🙂
The Hash structure provides a simple method for capturing this kind of information. If you can extract the key, then just capture the block of data you need, then either replace it, or use the first instance.
Example:
This is a common pattern for extracting delimited information from a log file. You will need to adjust the starting and fininishing regular expressions, of course.