in reply to Log Parsing using Regex

I'm a bit surprised that this can work. Is the SOH character directly in the log file or is it just the string '^A' ? I assume the latter since your regex seems to try to check for that

I said 'try' because a ^ has a special meaning, it matches the start of a string. You have to escape ^ to match your tags, so it is very astonishing that you say your pattern works

It is no surprise that your matches (however you get them) contain the ^A when the parenthesis used to catch the number are also around the ^A

A solution could be something like this:

while ($line =~ m/\^A(\d+)=(.*?)(?=\^A)/g){ my $tags{$1}= $2; } print $tags{55} || ''; print '|'; print $tags{22} || ''; print '|'; ...

I assume that you only want a few specific tags to print, otherwise you should use an array to have a defined ordering of the tags and print the tags in a loop over that array

Note the lookahead in the regex is necessary so that the following match is not stepping over every second tag