Is it possible to call a class method whose name is stored in a scalar variable? For example, consider the following code.
Cheers, Ron.package Class_A; sub Meth_U { ... } sub Meth_V { ... } sub Meth_W { ... } sub Dump_SV { my $self = shift; foreach my $a qw( U V W ) { my $method = "Meth_" . $a; # Call the method whose name is kept in a variable. $self->$method->(); # DOES NOT WORK } }
In reply to Class method names in a scalar variable by rongrw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |