Ken Foskey wrote:

I cannot get the syntax right for child lookup, Data::Dumper confirms
that I have the structure as I expect (logic may be totally wrong
though).  I going to do a webpage pstree command.

    foreach my $child (sort keys( $parent{$pid} )) {
        dump_process( $child );
    }

Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi
line 46, near "} )"

Initial $pid is zero and the entry looks like this:

            '0' => {
                     'ntp' => 1,
                     'hplip' => 1,
                     '1' => 1,
                     'klog' => 1,
                     'cupsys' => 1,
                     '101' => 1,
                     'root' => 1,
                     '117' => 1,
                     'avahi' => 1,
                     'user' => 1
                   },


As Perl has told you, keys() takes a hash, not hash element. $parent{$pid}
is an element whose value is a reference to that hash you're interested in,
so you must dereference that to provde a hash:

 foreach my $child (sort keys %{$parent{$pid}}) {
   :
 }

I hope this helps,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to