Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERL/CGI & PHP include

Status
Not open for further replies.

vietboy505

Technical User
Feb 20, 2006
56
US
I want to include a PHP file inside a PERL file..

script1.pl
Code:
#!/usr/local/bin/perl

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

print header();
warningsToBrowser(1);

print("<?php include('require_file.php') ?>\n\n");

It's in the source code, but it's never include my other php. How can I fixed that?
'require_file.php' is in the same directory the script1.pl is.
 
I include the PHP page because that is my layout design.
 
Perhaps I wasn't clear.

Your perl script outputs a PHP snippet. What do you do with that snippet? How are you getting PHP to execute it?



Want the best answers? Ask the best questions! TANSTAAFL!
 
php code config.php, this is the layout that I want.

should I do a for loop and print out each .php file instead?

Code:
<div id=menu style="float:left">
<?php include('nav_link.php') ?>
</div>

<div id="footer">
<?php include('copyright.php') ?>
</div>

<?php include('lastmodify.php') ?>

Code:
#!/usr/local/bin/perl

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
##use XML::Simple;

print header();
warningsToBrowser(1);

print("<?php include('config.php') ?>\n\n");
my $ref = XMLin('address.xml');

print <<TABLE;
<table border="1">
<tr>
<th>Type<th />
<th>Contact<th />
<tr />

TABLE

foreach my $cat (qw(XCOM YCOM)) {
		foreach my $type (qw(Work Relative)) {
   		my $count = 0;
   			foreach my $person (keys %{$ref->{$cat}->{$type}}) {
      			my $id=$ref->{$cat}->{$type}->{$person}->{id};
      			my $name=$ref->{$cat}->{$type}->{$person}->{name};
     			 $count == 0 ? print "<tr>\n<td>$type<td />\n" : print "<tr>\n<td><td />\n";
     			 print("<td><a href='../search.asp?ID=$id'>$name</a><td />\n<tr />\n\n");
     			 $count++;
  			 }
		}
}
print '<table />';
This print out a table of name in XML file. This PERL code work except PHP part, only print to browser only.
 
Yes, it should only print the output to the browser. Like a perl script, a PHP script must be run through an interpreter for execution. But since this is happening within the web server, instead of at the border between the web server and the internet, there will be no automagic mechanism that will execute the script.

Your scrip must explicitly invoke the PHP interpreter.



Want the best answers? Ask the best questions! TANSTAAFL!
 
I try this link, when I try in .pl file, it doesn't do nothing.
I also read this link, PERL in PHP

Code:
<?php 

    print "Hello from PHP!\n"; 
    $perl = new Perl(); 
    $perl->require("script1.pl"); 
    print "Bye!\n"; 

    ?>
Give me this:

Hello from PHP!
Fatal error: Class 'Perl' not found in C:\Inetpub\webaps\test2.php on line 4

I try include inside PHP script inside PERL script, doesn't work, so I try the PHP include of PERL file. No luck at all.

Do I need to import Perl class from PHP or something?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top