in reply to Re^2: undef a variable for a loop
in thread undef a variable for a loop

That's what it does already thanks to the leading /.+/. Well, you might have to replace the leading /.+/ with /(?s:.)+/ so that it matches newlines.