ktsirig has asked for the wisdom of the Perl Monks concerning the following question:

hi all! I have the following problem: I have a form containing a textarea. In the textarea, the user supplies his/her data in the form of

>seq1 MGTKGTIGTGRTKGTRGKTRKGTGKTRG >seq2 RTRTGRGRTGTRGTRGTGTGTRGTVTGTGTRGTRT

etc I want to pass each pair (containing of >seq and a sequence under it) into variables for a perl script. Is there a way to do it via PHP? How do you call the perl script in order to feed it the data?

Edit: g0n - added code tags

Replies are listed 'Best First'.
Re: PHP/PERL
by davidrw (Prior) on Sep 29, 2005 at 01:16 UTC
Re: PHP/PERL
by graff (Chancellor) on Sep 29, 2005 at 01:14 UTC
    Are you asking how to run a perl script from within a PHP script? Don't you have a book or manual or some other documentation about PHP that tells you how to run some other program from within a PHP script?

    When you figure out how to do that, it will probably involve passing a "command line string" to some PHP function for running a command line, and you'll have the option of putting "command line arguments" in that string, including, for example, the name of a perl script, and anything that the perl script needs in its @ARGV array on start-up (e.g. one or more file names, any optional flags, etc).

    Depending on what the perl script happens to be (I hope you have a man page or other docs on that as well), you'll need to figure out what you need to put into the command line string in your php script.

    E.g. you might need to save the ">seqN" labels and strings of letters in a file, and include the file name in the command line string that runs the perl script.

    This is not a place to ask questions about how to do things with PHP. If you're looking for help with a perl script, tell us what the script needs to do, show us what you've tried, and make it clear what sort of problem you're having.

    By the way, if you put "<code>" and "</code>" around your data, it will show up correctly in your post. You can update you post to fix that.

Re: PHP/PERL
by TedPride (Priest) on Sep 29, 2005 at 04:24 UTC
    If this is likely to be a large amount of data, one way to pass it from PHP to Perl would be to create a data file named according to IP or session code and then pass the session code to Per as an argument (see exec). This is probably the easiest method. Depending on what the Perl script does, however, it might be simpler to rewrite it in PHP rather than messing around with transferring back and forth between the two. I often write my first and second drafts in Perl and then translate to PHP once I have a handle on what I'm trying to do.