in reply to $var as accessor name?

You most definitely can use a variable as a method name. Your issue is you cannot use methods as lvalues (unless they have the lvalue attribute), which is different. (Only read =, not == ... LASIK must be fading)
package Foo; sub foo { print "Foo\n"; } sub bar { print "Bar\n"; } sub new { bless {}, shift } package main; my $foo = Foo->new; foreach my $method (qw( foo bar )) { $foo->$method; }
(The above code has been tested on Perl 5.8.0/Solaris9)

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: $var as accessor name?
by simonm (Vicar) on Mar 11, 2004 at 17:44 UTC

    With regard to $foo->$method, I believe that in some earlier versions (5.005?), the parenthesis are not optional:

    $foo->$method();

    Also with regard to $foo->$method = $value, note that because Proc::ProcessTable::Process doesn't use lvalue accessors, you need to pass the value as an argument:

    $foo->$method( $value );