4 Replies - 204 Views - Last Post: 01 May 2013 - 02:49 PM Rate Topic: -----

#1 Zel2008  Icon User is offline

  • D.I.C Addict

Reputation: 14
  • View blog
  • Posts: 763
  • Joined: 06-January 09

Creating a PHP wrapper for Perl

Posted 25 April 2013 - 08:04 AM

Hi all,

I've inherited some very old and difficult Perl code, using lots of global variables, hardcoded HTML, and hardcoded Javascript (all in the Perl). I've been given the task of making this mishmash cross-browser functional and compatible, and the code just isn't cooperating -- there are so many pieces scattered in so many places that it's just not working out.

Unfortunately, rewriting the code is out of the question.

So, I came up with the idea of creating a PHP wrapper for the Perl, letting the scripts do their thing, and then modifying the output with PHP before it gets sent to the browser. It's a pretty awful kludge, but I think it should work. The only way I know how to do this is in something similar to the following:

<?php
system( "perl script.pl" );
?>



This works fine as long as the script doesn't have any command line arguments, but most of the scripts pass global variables between each other and a database with CGI. Those variables are needed to figure out what HTML pieces are being shown in a given script, and we don't know what they are until the script begins to run.

Is there a way in PHP to interrupt the execution of the script so we can get these variables, and then continue with the PHP wrapper?

Thanks,
Zel2008

Is This A Good Question/Topic? 0
  • +

Replies To: Creating a PHP wrapper for Perl

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: Creating a PHP wrapper for Perl

Posted 25 April 2013 - 08:53 AM

I'm confused. Are you saying that you want to run a php script that calls a perl script which then calls another perl script? If so, shouldn't the first perl script already be passing arguments to the second?
Was This Post Helpful? 1
  • +
  • -

#3 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7293
  • View blog
  • Posts: 12,105
  • Joined: 19-March 11

Re: Creating a PHP wrapper for Perl

Posted 25 April 2013 - 09:30 AM

You want to start and stop the perl from the PHP? I could understand that if the perl were setting up something with state and an API that you could talk to, but I don't think that's happening.

I think you're going to have to reconsider the "not an option" part of your brief.

Quote

So, I came up with the idea of creating a PHP wrapper for the Perl, letting the scripts do their thing, and then modifying the output with PHP before it gets sent to the browser. It's a pretty awful kludge, but I think it should work.


You're half right: it's a pretty awful kludge. But I see no reason why it should work, and if by some mis-miracle it does work, then you're only setting up an exponentially worse problem for later.
Was This Post Helpful? 1
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3392
  • View blog
  • Posts: 9,586
  • Joined: 08-June 10

Re: Creating a PHP wrapper for Perl

Posted 25 April 2013 - 10:25 AM

out of interest, why is rewriting the code out of question?
Was This Post Helpful? 1
  • +
  • -

#5 Zel2008  Icon User is offline

  • D.I.C Addict

Reputation: 14
  • View blog
  • Posts: 763
  • Joined: 06-January 09

Re: Creating a PHP wrapper for Perl

Posted 01 May 2013 - 02:49 PM

Hi everybody,

Sorry, I thought I replied to this thread. The rewriting was out of the question because at the time of posting, I wasn't allowed to change the language the program was written in. I've been given the green light to do so, though, so this question is now moot.

Thanks,
Zel2008
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1