in reply to Re: Calling a subroutine from a scalar
in thread Calling a subroutine from a scalar
Well, I left you neutral, but I suspect it's because one can use eval, and that doing what the poster is asking needn't be "deep magic" or responded to with what was essentially "you don't want to do that" without even a brief explanation of why.
For the record, eval could be used thus:
You are right to say that there are many, many reasons why one doesn't want to use eval this way[0], and that there is probably a better solution. However, I would say that the OP simply didn't provide enough information about what (s)he is trying to accomplish for us to provide useful advice on what approach could prove safer and more efficient.my $f = 'subroutine'; eval "$f"; sub subroutine { print "In sub!\n"; }
[0]: A few reasons, from the top of my head:
Yoda would agree with Perl design: there is no try{}
|
|---|