As the title says, in Perl, how can I save a hash that contains a list of subroutine references? For example, I have the following hash that contains the references to the subroutines which are contained in other libraries:
my %testMap = (
helloTest => \&runHello,
goodbyeTest => \&runGoodbye,
);
When I try to use Data::Dumper in the following matter:
my($out) = new FileHandle ">$fileName";
my $serialized => Data::Dumper->Dump([\%testMap], [$HASH_REFERENCE]);
print $out $serialized;
close $out;
I end up with a file that looks like the following:
$testMap = {
'goodbyeTest' => sub { "DUMMY" },
'helloTest' => sub { "DUMMY" }
};
When I would like the output to look like what appears in the original listing, is there a way to do this?
Some experimentation with Data::Dumper and Storable have so far turned up nothing and I suspect that it is due to the actual code for the references not being available to the code that is running.