lapenta[ wrote:
> Hi Paul,
>
> Gee thanks for the help, worked like a charm.
Quite welcome. Glad I could help.
> > &{${$g_module.'::'}{eqn}}(5,6);
>
> woah, that is quite a nutty statement. if anyone has a more readable
> approach I would certainly be interested.
See the post elsewhere in this thread by Steven. It didn't occur to me
to take full advantage of the fact that I'd already turned off strict's
symref checking. As Steven said, the above can be more concisely
written:
"${g_module}::eqn"->(5,6);
Note two important things here: strict 'refs' must be turned off, and
the Quotes are required. What's happening is that we're generating a
string containing the characters "foo::eqn", and then using that string
as a symbolic reference. The arrow notation dereferences that symbolic
reference and calls the resultant function.
In my original, I was generating the string "foo::", and then using
that string as a symbolic reference to the hash %{'foo::'}. This is
the symbol table for the package foo. I then accessed one element of
that symbol table - keyed at the string 'eqn' - to obtain the *foo::eqn
typeglob. The & and () were then used to access the subroutine piece
of that typeglob and call the function.
All in all, I'd say Steve's solution is far better.
Paul Lalli