Is it possible to define anonymous subroutines in a hash constructor in Perl?
I'm trying to do something like this:
my %array = { one => sub { print "first $_[0]" },
two => sub { print "next $_[0]" },
three => sub { print "last $_[0]" }};
$array{$foo}->('thing');
But it isn't working. The code seem...
This is the code:
sub function($&) {
my $param1 = shift;
my $code = shift;
# do something with $param1 and $code
}
If I try to call it like this:
function("whatever") {
print "i'm inside the coderef\n";
}
I get Not enough arguments for MyPackage::function at x.pl line 5, near ""whatever" { ". How can I call it witho...
I was usually using Storable with nstore, but now I have a module that has CODE and apparently Storable doesn't like that.
I found YAML (and YAML::XS which I can't really get to work).
I also experimented a bit with MooseX::Storage without much success.
Are there other alternatives?
What would you recommend?
...