Jun 27, 2014, 8:43 AM
Post #1 of 2
Let me preface that I am neither a perl nor php expert. I have some legacy perl scripts in which I now need to add some php calls (the API in question is only available in php). I don't have time to learn how to recode all my scripts in php.
Passing a variable from perl to php?
I am using the (seemingly no longer supported or updated) PHP::Interpreter module:
I've got everything working as long as what php is working with is static content or variables created within the php code. It actually works well. The problem comes when I need to access data in a perl variable from within the php code. The above documentation makes reference to passing parameters to php but only supplies an array-based example. I tried going that route to no avail; I think it may be a syntax issue, but I'm too dain bramaged to see where the problem lies.
The following code is an ultra-simple distillation of the problem.
I'm missing the forest for the trees. Thank you.
# LOTS OF PERL CODE PRIOR TO THIS POINT
my $perlvar = "a lovely bunch of coconuts.";
my $p = PHP::Interpreter->new(PHPVAR => $perlvar);
# BEGIN PHP CODE
echo "I have got " . $PHPVAR;
# END PHP CODE
# MORE PERL CODE AFTER THIS POINT