# Not tested and assumes proper nesting of
elements (and valid XML syntax) # (Warning: Messy hack. Read at your own risk.) my $nest = 0; my $out = ''; my @elements = $xml =~ /$XML_SPE/g; # see http://www.cs.sfu.ca/~cameron/REX.html#AppA for (@elements) { if (/^
0); # only increment if inside an interesting
next unless (/class\h*=\h*['"]data['"]/); # \h is horizontal white space next unless (/id\h*=\h*['"](\w+)['"]/); $out .= ", $1="; $nest = 1 if ($nest == 0); # if this is the outer most interesting
next; } $nest--, next if (/^<\/div/); next if (/^[<]/); # skip other mark-up $out .= $_ if ($nest > 0); } $out =~ s/^, //; say "$out\n";