How to Pass Inputs From PHP to Perl

When programming for the Web, you may use PHP on one part of your website or application and Perl in another to process different functions and perform different tasks. It is possible to pass data and arguments between PHP and Perl, both of which are scripting languages that can be used to create rich Internet applications. It's common for both to be found in the same development environment, so knowing how to make the two languages interact can be useful.

Instructions

    • 1

      Open the PHP file that you want to edit in a plain text editor such as Notepad or a programming application such as Zend Studio.

    • 2

      Initiate the interaction with Perl by calling two functions and the initial argument as demonstrated in the example of code below:

      #!/usr/local/bin/perl

      chomp($which_file=@ARGV[0]);

      chomp($split_val=@ARGV[1]);

      if (length($which_file)==0||length($split_val)==0)

      {print "Hello World!\n";}

    • 3

      Provide the alternative for the argument in PHP as follows:

      else

      {

      if (!-e $which_file)

      {print "$The World isn't around right now\n";}

      else

      {

      open (spfile,"<$which_file") or die ("Can't read $which_file");

      $temp_var=<spfile>;

      close spfile;

      @split_arr=split(/$split_val/,$temp_var);

      $new_file=$which_file.".split";

      open (newf,">$new_file") or die ("Can't create $new_file");

      close newf;

      }

      }

    • 4

      Save the PHP file and upload it to your Web server to test it in the production environment.

Related Searches:

References

Comments

Related Ads

Featured