The regular expression doesn't change, so you should notify Perl that it's safe to compile it once,. rather than each time that line is encountered. For two invocations, it obviously doesn't matter, but small scripts have a habit of growing, so you might as well get off to a good start right away: if /$PRE($VALID1+)$PST/o
You parenthesize $Valid1 twice, once as the last character of $PRE and the first character of $PST, then explitly when you string them together: /$PRE($VALID1+)$PST/.