Unmatched ( before HERE mark in regex m/begin # Start with 'begin', ( << HERE ?: # Followed by (?>[^be]+) # Not a b or e, many times, |b(?!egin) # Or a b not starting 'begin', |e(?!nd) # Or an e not starting 'end', |(??{ $re }) # Or a balanced begin/ at fudge line 6.