$foo = "1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890 1234567890123456789012345678901234567890"; if ($foo =~ m/4 lines of 0 to 40 chars in length/) { do something }