in reply to Parse::RecDescent and nesting
gives the following output+ use strict; use Parse::RecDescent; my $parser = Parse::RecDescent->new(q( start: part(s) { print join("\n",@{$item[1 +]}); } part : stag part(s) etag { $return = "$item{stag +} " . join(" ", @{$item[2]}) . " $item{etag}"; } | stag data etag { $return = "$item{stag +} $item{data} $item{etag}"; } | data data : m{([^<]+)} stag : m{<open\d>} etag : m{<close\d>} )); $parser->start(<DATA>); __DATA__ <open1> Some content <close1> <open2> some <open3> more content <close +3> <close2>
The formatting of the second clause can be twekaed with the join char.<open1> Some content <close1> <open2> some <open3> more content <close3> <close2>
|
|---|