2

I have developed a tagger to tag terms of a particular domain. For the tagging purpose I used Perl. The tagger tags abstracts from the literature, I have developed an interface that actually collects the user input. My question is how can I take the data from the interface and pass it to the Perl script as an array and also how to display the output after processing from the Perl script.

I have the necessary tagging script just cannot figure out the above problems.

I got few suggestion using JSON. So am I suppose to have two different scripts, one php and other the perl that I have. And what about displaying the processed file automatically

3 Answers 3

4

You probably need to use a data marshaling protocol. Two easy possibilities (for PHP and Perl) are:

  • JSON output -> JSON input.
  • YAML output -> YAML input.

JSON

In PHP:

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, json_encode( $struct ));
fclose($fh);

In Perl:

use File::Slurp qw<read_file>;
use JSON qw<from_json>;

my $struct = from_json( read_file( 'testfile.txt' ));

YAML (a superset of JSON)

In PHP:

yaml_emit_file( "testfile.txt", $struct );

In Perl:

use File::Slurp qw<read_file>;
use YAML::XS qw<Load>;

my $struct = Load( read_file( 'testfile.txt' ));

As well, there's good ol' fashioned XML, but to make that nearly as easy you'd have to use Pear in PHP. But XML::Simple could make it about as easy.

Sign up to request clarification or add additional context in comments.

3 Comments

+1 for JSON. Both PHP and Perl (with the JSON module) make it ridiculously easy to pass JSON strings around and decode them.
Can anybody give me a detailed explanation
@nandini - You've received a detailed explanation. What about the explanation confuses you?
2

There are a number of options.

Comments

1

If you use two different languages like php and java or c or anything else you have to use a standard format language to communicate between them . to do that you should use websevices that uses the SOAP protocol with xml that is ... this is my recomandation and I think that is the best solution because its solving many problems and am using it right now to communicate between android application and java EE web application.

1 Comment

SOAP is unnecessarily complicated for most use cases.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.