On Tuesday 17 August 2010, Nicolas RĂ¼ger wrote:
thanks for the help. Your idea kept me trying as the C-code shows that it should return the result from the PERL subroutine as you already mentioned in your answer.
Two points I want to name here:
I'm still confused that the methods in perl/perlfunc.c are called "perl_exec1()" and "perl_exec2()" instead of "perl_exec" because that's the one for use in kamailio.cfg.
Hey Nicolas,
this is not defined in the C, but in the module interface. Take a look to the perl.c:static cmd_export_t cmds[] variable.
- More Important...
I finally solved my issue by using a variable in kamailio.cfg:
if (is_method("INVITE")) { $var(a) = perl_exec("my_perl_subroutine"); if ($var(a) == -1){ xlog("PERL returns -1 \n"); } }
That works!
So is this behavior of kamailio.cfg a bug? It should at least be listed in the documentation cause it's really tricky.
PLEASE NOTE:
perl_exec("my_perl_subroutine") == -1 --> returns FALSE
BUT
$var(a) = perl_exec("my_perl_subroutine"); $var(a) == -1 --> returns TRUE
This is indeed strange. I'd say that evaluating the return value of a function is nothing that new, its has been a pretty long time there. Maybe the comparison went somehow mad because of some typing issue? Another idea, have you tried using the $rc PV, which also return the result of the last called function?
Regards,
Henning