in reply to Validating a Code Reference
Think of anonymous subs, for example:
That prints outprintf "%s\n", sub { "foo" };
The tricky thing that I'm pointing out here is that you certainly couldn't "look up" an anonymous sub to ensure that it exists; but the code reference looks just like a reference to a named subroutine, and if you doCODE(0x45f73b0)
you'll get "CODE" either way. In other words, a reference to an anonymous sub looks just like a reference to a named sub; and if you can't look up one then you may not be able to look up the other. :)my $type = ref $sub;
The only "solution" really may be to try and run the sub. I guess the problem here is that the only way of dereferencing a code reference is to *run* it; and that's what you want to avoid. But if that's the only way, then... anyway.
I hope to see some more encouraging answers, though.
|
|---|