Indirect method invocation


it does not seem to be possible to use indirect method invocation with anything but a scalar. While this works:

my $mode = $parameters{mode};

I cannot seem to find a proper bracketing to make this work:


Is my assumption correct?

My other problem is that the cookbook quotes (something like) the following code as an example for storing method names:

my %actions = (
display => $item->display(),
move_picture => $item->move_picture($item->{id}, $item->{parameters}->{position}),
commit => $item->commit()

Now I thought I could use


to invoke the proper method, but I get a "Useless use of hash element in a void context" error.

I can see why I get that error - but why would someone want to build a hash like %actions then, which just maps names to method invocations, without a way to actually get to those method invocations?

In other words, I would like to have something like the %actions hash to construct a more flexible version of the $item->$mode() construct, where I can pass different additional parameters to each method.



I have known more men destroyed by the desire to have wife and child and to keep them in comfort than I have seen destroyed by drink and harlots. - W.B. Yates