c:\> perl -n -e "print if /^PARTNAME/ && /PARTNAME$/ && $last; $last = /^xyzdf/ && /.xyzdf$/ ? $_ : ''" file1>file2