Exetending your requirements a little, there is a neat feature that is useful when replacing tokens, like your HEADER and REMARK. You can execute code from within a substitute statement, for example:
$line =~ s/(HEADER|REMARK)/mysub($1)/ge;
That will call user-written subroutine mysub every time HEADER and REMARK are found in the text. The argument passed is the text matched inside (). Whatever is returned by mysub will replace the token. It probably would not be worth it for the simple substitution you mentioned, but for more complex combinations it can be very powerful.