foreach () { if (/PatternBegin/ .. /PatternEnd/) { $str .= $_; } }