my $a= qr{]*>}; my $c= qr{]*>}; my $d= qr{}; for( $body ) { die "No $a" if ! /$a/g; my $start= pos(); die "No 1st $c" if ! /$c/g; die "No 2nd $c" if ! /$c/g; die "No 3rd $c" if ! /(?=$c)/g; my $end= pos(); pos()= $start; die "No 3rd $c before $d" if /$d/g && pos() < $end; return substr( $_, $start, $end-$start ); }