sub foo::test { print "test" } my $x = "foo"; my $sub = $x->can("test"); $sub->()