$_ = "foo\n Oops"; print /^(?=.{0,50}$).*foo/i ? "Matches!" : $_;