So, I imagine the headers will never have a time in them?
Time has a a ":" in it that should be unique to them.
So maybe instead of :
if ($line =~ /^\b\d/)
You could use
if ($line =~ m/:/)
I didn't test it since I don't have a sample of your input, but something along those lines should process your steps only if the lines have a colon in them.
Alternatively, if the headers and only the headers contain "perf" in them, you could do
if ($line !~ m/perf/)
| [reply] [d/l] [select] |