how to include .pl (PERL) file in PHP
Posted
by dexter
on Stack Overflow
See other posts from Stack Overflow
or by dexter
Published on 2010-04-14T07:32:35Z
Indexed on
2010/04/14
7:52 UTC
Read the original article
Hit count: 498
i have two pages one in php(index.php) and another one in Perl(dbcon.pl).
basically i want my php file to show only the UI and all the data operations would be done in Perl file.
i have tried in index.pl
<?php include("dbcon.pl");?>
<html>
<br/>PHP</br>
</html>
and dbcon.pl has
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
use CGI::Simple;
my $cgi = CGI::Simple->new;
my $dsn = sprintf('DBI:mysql:database=%s;host=%s','dbname','localhost');
my $dbh = DBI->connect($dsn,root =>'',{AutoCommit => 0,RaisError=> 0});
my $sql= "SELECT * FROM products";
my $sth =$dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
while (my @row = $sth->fetchrow_array){
print $cgi->header, <<html;
<div> @row[0] @row[1] @row[2] @row[3] @row[4]</div>
html
}
but when i run index.php in browser it prints all the code in dbcon.pl file instead of executing it
how to overcome this problem?
note: i am running this in windows environment
is there any other way to do this?
© Stack Overflow or respective owner