some another lines =begin some lines some lines =end some another lines... #### while () { if(/=begin/) { read the next line. check whether the line is "=end" or not... If it "=end" stop the read operation. Otherwise continue the read process. } }