in reply to how to cut context between first "begin" and "end"?

from the command line:
perl -pe '$skip=0 if /^end$/; next if $skip; $skip=1 if /^begin$/' dat +a.txt

Or a little more drawn out:

#!/usr/bin/perl use warnings; use strict; my $skip=0; while(<DATA>) { $skip=0 if /^end$; print unless $skip; $skip=1 if /^begin$/; } __DATA__ a begin 1 <----- delete a <----- delete 2 <----- delete end c begin c end a begin 1