perl -pe '$skip=0 if /^end$/; next if $skip; $skip=1 if /^begin$/' data.txt