$/ = "First line of text"; while () { if(/[\n]second line of text[\n]in the third line I have (\d*\.\d*)/s) { print "Captured ($1)\n"; } }