in reply to Question on RE based matching

You probably want the s modifier to the match, so the dot in .* will also match the newlines — i.e. if (/ ... /s) {.  (In addition to that, you have to make sure that you have the entire HEADER(...) entry read into the string you're matching against, e.g. by setting the input record separator $/ appropriately, or by accumulating the lines starting from 'HEADER(' up to ')' ...)