matija has asked for the wisdom of the Perl Monks concerning the following question:
It should use Proc::ProcessTable to look at each process in turn, and return all the data it has on the processes that match each description.
The problem is, Proc:ProcessTable returns an object, where every property of a process is an accessor method for that object.
Obviously, I can't do $p->$key==$val, much as that would come in handy right now.
I think that I need to either do something ugly with eval, or create a chain of ifs like if ($key eq 'cmdline') {$match=$p->cmdline} elsif ($key eq... etc.
The matter is made more complicated because I have to return data about the process in a hash - I'm not allowed to just return a Proc::ProcessTable::Process object. That means that even if I use a series of ifs in the matching part, I still need a solution for the reporting part.
I was thinking of dispensing with Proc::ProcessTable altogether and just parsing the output of ps, but this code needs to run as transparently as possible on at least Linux and Solaris...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $var as accessor name?
by broquaint (Abbot) on Mar 11, 2004 at 15:04 UTC | |
by matija (Priest) on Mar 11, 2004 at 20:14 UTC | |
by ysth (Canon) on Mar 12, 2004 at 04:46 UTC | |
by BrowserUk (Patriarch) on Mar 12, 2004 at 05:32 UTC | |
by ysth (Canon) on Mar 12, 2004 at 07:33 UTC | |
|
Re: $var as accessor name?
by dragonchild (Archbishop) on Mar 11, 2004 at 14:50 UTC | |
by simonm (Vicar) on Mar 11, 2004 at 17:44 UTC | |
|
Re: $var as accessor name?
by Fletch (Bishop) on Mar 11, 2004 at 14:53 UTC | |
|
Re: $var as accessor name?
by Juerd (Abbot) on Mar 11, 2004 at 14:49 UTC |