{ # Read all of __DATA__ into $_: local $/; $_ = ; } while (/(\d)\n{2}/g) { print "$1\n"; } __DATA__ Line 1 Line 2 Line 3 Line 5 Line 6 Line 7 Line 9