in reply to Call to subs in a Dispatch Table
With "at the same time" you don't want to say "in parallel", do you?
If you want to call the code from the "data" key, you can do so if you separate declaration from assignment, like thisthen you can call it from "inside", like this:my %general; %general = ( ...
BEWARE this creates a circular reference, which probably won't be a problem here, but you should be aware of the fact.results => sub { names( first => $q->param('first'), zip => $q->param('zip'), ); $general{data}->(); },
Update: OOPS! of course I didn't mean to call $general{results} - thanks AnomalousMonk - corrected
Further Update: obviously, the interpreter is less strict than the manual: according to perlref I'm allowed to say &{$general{data}}() ("method 2") or $general{data}->() ("method 3", but when I tried it out before posting (with a simpler example), the syntax $general{data}() also worked. Perhaps this is a version specific thing (strawberry 5.14.2.1)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Call to subs in a Dispatch Table
by AnomalousMonk (Archbishop) on May 08, 2015 at 13:54 UTC | |
|
Re^2: Call to subs in a Dispatch Table
by AnomalousMonk (Archbishop) on May 10, 2015 at 07:23 UTC |