[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Perl Query.



This following declaration of $a is not a reference to a function.

$a = 'sub output { print "Hello World\n"; }';

This is some thing like stored procedure. Here $a is a string containing the function
code. Well I have got one way of executing that. This is as follows:

eval $a;
&output();

  But here I require to know the function name for executing. If I don't know the name
of the function, I cannot execute this function, directly without parsing the string.

Actually I want to implement the "stored procedure" facility. I came up with this
method of storing the function as a string and trying to execute the function. In case
there is a better way of doing this, I am very much eager to know.

TIA,
mallik.


Mithun Bhattacharya wrote:
> 
> You have defined a reference to a function here - assuming that peice of
> code was in Perl. In that case &$a() would execute your function. Seems
> a highly unusual thing to do unless you are making a array of functions
> and things like that ....
> 
> Mithun