while(<>) { if(/Start/ .. /End/) { print } } #### { local $/; my $input = <>; if(/ Start(.*)? End/sg) { print $1 } }