in reply to Parse::RecDescent and nesting

I think you want something like the following.
use strict; use Parse::RecDescent; my $parser = Parse::RecDescent->new(q( start: chunk(s) chunk: tag | raw tag : stag raw etag { print "tag: $item[1] $item[2] $item[3]\n"; #$return = "$item{stag} $item{raw} $item{etag}" $return = "$item[1] $item[2] $item[3]"; } | stag raw tag(s) raw etag { print "tag: $item[1] $item[2] $item[3] $item[4] $item[5]\n"; #$return = "$item{stag} $item{raw} $item{etag}" $return = "$item[1] $item[2] $item[3] $item[4] $item[5]"; } #outputs: #tag: <open> tag 1 <close> #tag: <open> tag 2 <close> #tag: <open> tag 3 b <close> #tag: <open> tag 3 a ARRAY(0x1a55ad8) tag 3 c <close> #tag: <open> tag 4 b <close> #tag: <open> tag 4 d <close> #tag: <open> tag 4 c # ARRAY(0x1a8f664) tag 4 e # <close> #tag: <open> tag 4 a # ARRAY(0x1a8f670) tag 4 f # <close> raw : m{([^<]*)} stag : m{<open>} etag : m{<close>} )); #slurp mode local $/=''; $parser->start(<DATA>); __DATA__ <open> tag 1 <close> notatag 1 <open> tag 2 <close> notatag 2 <open> tag 3 a <open> tag 3 b <close> tag 3 c <close> notatag 3 <open> tag 4 a <open> tag 4 b <close> <open> tag 4 c <open> tag 4 d <close> tag 4 e <close> tag 4 f <close> notatag 4
I am 95% happy with this code. If only I wasn't getting those ugly hex refs in the output.

Maybe some other monk can help with that :)

thomas. UPDATE: Follow up at Parse RecDescent Nesting (Followup)