Thomas Bätzler <t.baetz...@bringe.com> writes: >> sub func { %h = ( N => sub { print N(@_) . "\n"; } ); } > > If you call the sub like this, it'll create the hash %h containing the > key "N" associated with a code reference to an anonymous > subroutine. When that subroutine is called it will pass its _current_ > argument list to function N, then print the returned values from that > function and a line feed. > > If you wanted that code reference to be called with the values of @_ > at the time of its creation, you'd have to use a closure and keep a > copy of the values in a lexical variable, probably a bit like this:
Thanks. Your example helped .. At least now I can see how it might be done. if it really was required. I'm thinking now though that I was abusing the dispatch table, trying to get more done that could be better done other ways. First by letting the functions called in the table work on global information, instead of trying to pass it through the table. Philip P.s' explanation and now your example of how to do something like that using the `closure' approach, made me see I was going at it a bit wrong to start with. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/