in reply to $var as accessor name?

You could always just extend Proc::ProcessTable e.g
sub match { my($self, @matches) = @_; my @fields = $self->fields; my @ret; for my $p (@{ $self->table }) { push @ret => { map {; $_ => $p->$_ } @fields } if grep { my $val = $_; grep { $p->$_ =~ $val } @fields } @matches; } return @ret; }
That will return a list of hashes, each containing the information for each process where one of the fields matched one of the match values.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: $var as accessor name?
by matija (Priest) on Mar 11, 2004 at 20:14 UTC
    Thank you, everybody, for pointing out my blind spot.

    I guess when you're wondering if Perl can do something, you should try it first, because usualy it does :-)

    Special thanks to broquaint for this lovely code.

      If the method name is a variable, it does have to be a simple scalar (e.g. $obj->$hash{method_foo} won't work).

        That's not strictly true, though it is messy.

        { package test; sub new{ return bless [], $_[0]; } sub meth1{ print 'meth1'; } }; $t=test->new; $t->meth1; meth1 $h{x}='meth1'; $t->${ \$h{x} }; meth1

        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail