oxone has asked for the wisdom of the Perl Monks concerning the following question:
I presume the answer is no, and that the scalar value of the coderef - eg. CODE(0x225c2c) etc. - is just a memory location of no use in this context as it may be different if code is the same, or indeed the same even if the code is different.my $coderef = sub{ return "Hello"; }; # Possible somehow to manipulate $coderef # here, to get back to the code itself?
My planned workaround is for the module to accept code as string values instead of coderefs, and then 'eval' them into coderefs inside the module, but this doesn't seem very elegant.
Is there a better way?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Converting a coderef back to code
by Bloodnok (Vicar) on Apr 24, 2009 at 12:21 UTC | |
Re: Converting a coderef back to code
by citromatik (Curate) on Apr 24, 2009 at 12:23 UTC | |
by oxone (Friar) on Apr 24, 2009 at 12:34 UTC | |
Re: Converting a coderef back to code
by Anonymous Monk on Apr 24, 2009 at 12:09 UTC | |
by oxone (Friar) on Apr 24, 2009 at 12:20 UTC |