{ local $/=""; $file=; } #Now you can regex with m//mg all you want #### while(){ chomp(); $line.=" " .$_; #This adds a space between each line if (/\;$/) { #This works as long as the last char on the line is ;, may need to be tweaked. #regexes go here $line=""; }