while () { if ( /^Start:\s/ .. /^Close:\s/ ) { # here you can collect your lines } }