Re: suppressing __VALUE__ in <autotree>
[email protected] (Aamer Akhter) Sat, 15 May 2004 09:39:12 -0400
| Newsgroups | perl.recdescent |
|---|---|
| Message-ID | <[email protected]> |
On May 15, 2004, at 9:32 PM, Ted Zlatanov wrote: > On Fri, 14 May 2004, [email protected] wrote: > >> ;-) The above is possible, but why post-process the created struct >> when you don't need to put in __VALUE__ at all? > > Because <autotree> is a generic feature, and you're asking for > something very specific. At least that's my view of it. I agree. I was able to get what I wanted via this: $::RD_AUTOACTION = q{ if ($#item==1 && ($item->isterminal || ref $item[1] ne 'ARRAY')) { $return = $item[1]; } else { foreach my $i (keys %item) { if ($i=~ s/(\([\?s]\))$//o) { $item{$i} = \@{$item{$i.$1}}; delete $item{$i.$1}; } } $return = bless \%item, $item[0]; } }; which also cleans up the (s) and (?) return names, so I'm happy. It's great that prd was do well designed to be customizable. Hopefully, $item->isterminal is something that'll stick around for a while. > > It's humbling to see the XML::Simple options, for instance, that have > to deal with collapsing key-value pairs. Do you really want > <autotree> to be something that complex? > >> I understand the need for it for some applications. But other ones >> (eg when converting the returned hash to xml via xml::simple) only >> add a level of unneeded indirection. > > Speaking of the devil :) > lol > Ted > > -- Aamer Akhter / [email protected] NSITE cisco Systems