Suppose I have a function foo
(or ::foo
, or main::foo
if you prefer), and I define
use strict;
my $sub_name = 'foo';
I want to invoke foo
indirectly, as "the function whose name is stored in $sub_name
". (For the sake of this example, assume that the invocation should pass the list 1, 2, 3
as arguments.)
I know that there's a way to do this by working with the symbol table for main::
directly, treating it like a hash-like data structure.
This symbol-table incantation is what I'm looking for.
I've done this sort of thing many times before, but I have not programmed Perl in many years, and I no longer remember the incantation.
(I'd prefer to do this without having to resort to no strict
, but no biggie if that's not possible.)