CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Passing a variable from perl to php?

 



SkullCrusher
New User

Jun 27, 2014, 8:43 AM

Post #1 of 2 (420 views)
Passing a variable from perl to php? Can't Post

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.

I am using the (seemingly no longer supported or updated) PHP::Interpreter module:

http://search.cpan.org/~aff/PHP-Interpreter-1.0.2/lib/PHP/Interpreter.pm

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.



Code
#!/usr/bin/perl 

use PHP::Interpreter;

# LOTS OF PERL CODE PRIOR TO THIS POINT

my $perlvar = "a lovely bunch of coconuts.";

my $p = PHP::Interpreter->new(PHPVAR => $perlvar);


$p->eval(q~

# BEGIN PHP CODE

echo "I have got " . $PHPVAR;


# END PHP CODE

~);

# MORE PERL CODE AFTER THIS POINT



FishMonger
Veteran / Moderator

Jun 27, 2014, 9:13 AM

Post #2 of 2 (391 views)
Re: [SkullCrusher] Passing a variable from perl to php? [In reply to] Can't Post

Cross posted at http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_28465156.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives