my $success; while(/PATTERN/g) { if(substr($_, 0, $-[0]) =~ /LOOKBEHIND\z/) { # got a match! $success = 1; last; } }