Re: suppressing __VALUE__ in <autotree>

[email protected] (Aamer Akhter) Fri, 14 May 2004 12:24:12 -0400
Newsgroups perl.recdescent
Message-ID <[email protected]>
On May 14, 2004, at 10:26 AM, Ted Zlatanov wrote:

> On Thu, 13 May 2004, [email protected] wrote:
>
>> Is there a way of supressing the __VALUE__ hash that is added via a
>> single terminal return in <autotree>? Right now I have to play silly
>> little games on the return values. I realize that I could add my own
>> return handler but <autotree> is _so_ nice otherwise.
>
> Why not just remove it?  Untested code follows...
>
> sub remove_VALUE
> {
>  my $hashref = shift @_;
>
>  delete $hashref->{__VALUE__};
>  remove_VALUE($hashref->{$_}) foreach keys %$hashref;
> }
>

;-) The above is possible, but why post-process the created struct when 
you don't need to put in __VALUE__ at all? 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. 
But perhaps my problem is not really that common...


eg:
   <cpu_line(s)>
     <name>DHCPD Database</name>
     <0></0>
     <fiveMin>0.00</fiveMin>
     <fiveSec>0.00</fiveSec>
     <invoked>1338361</invoked>
     <oneMin>0.00</oneMin>
     <pid>
       <__VALUE__>112</__VALUE__>
     </pid>
     <runtime>32</runtime>
     <tty>uSecs</tty>
     <uSecs>0</uSecs>
   </cpu_line(s)>

To get around this I have to do this:
     $return = {
	pid=>$item{num}{__VALUE__}


btw the value of interest is actually inside __VALUE__ so you'd have to 
return the value of __VALUE__ and set it to the parent.

> Ted
>
>

-- 
Aamer Akhter / [email protected]
NSITE cisco Systems