http://www.perlmonks.org?node_id=11125028


in reply to How can I call a Perl sub with an object from a sub name stored in a var?

I think this is backwards. If you're thinking of $myargs to literally unpack to conform to caller semantics, then I'd lose that notion. Just unpack the contents of $_[1] as needed in the resolved subroutine that ends up being called.
use strict; use warnings; package Foo; sub new { my $pkg = shift; my $self = {}; return $self, $pkg; } sub dispatch { my ($self, $mysub, $myargs) = @_; $self->$mysub($myargs); return; } sub mysub1 { my ($self, $args) = @_; foreach my $arg (split /,/, $args) { print qq{$arg\n}; } } package main; my $foo = Foo->new; $foo->dispatch('mysub1', '1,2,3');

Output

prompt$ perl test.pl 1 2 3