Jump to content

Recommended Posts

I am hoping to add onto a Perl program. I am not ready to learn Perl yet and rewriting it all in PHP is not an option right now.

I am looking for the best options for getting this to work.

I have a config.pl file I want to include into a PHP file and use the values defined.
At present when I include it I end up with it being passed as if it were a text file and it displays the contents in the browser.

My current feeling is to save the contents to a string, change all the # commenting to either // OR just delete it, but then how to I use the values defined?

Is there a simpler way of doing this, perhaps telling the server to regard the perl file as a php one & not text?
Link to comment
https://forums.phpfreaks.com/topic/4052-including-perl-into-php/
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]#!/usr/bin/perl -w

# The following parameters are specified by the user.
# Blah Blah
# about the program
# and such.

$DatabaseName = "superblah";
$DatabaseAccount = "bee";
$DatabasePassword = "bub";
$DatabaseHost = "localhost";

$nMaxSearchResults = 100; # Number of search results returned per page
$szDateFormat = "%d %b %Y";
$szSearchPage = "../search.htm"; # URL for the search page link at the bottom of reports
$szLoginPage = "../login.htm";# URL for the login page - displayed on invalid login
$nPictureGens = 2;# set to the number of generations (starting from parents) to include photos
$szPhotoPath = ""; # this is prefixed to all photo paths
$nPhotoWidth = 150;# Pixel width of photo displayed in Pedigree
$szSuccessLoginPage = "../search.htm";# page which is displayed after successful login
$szFailLoginPage = "../fail_login.htm";# page which is displayed after failed login
$nDaysToKeepLogs = 60;# activity older than this many days is deleted from the logs
$szMailProg = "/usr/sbin/sendmail" ;
$szMailRecipient = "support\@blah.com" ; # make sure to \ escape the @
$szUserFields = "COI~Country of Origin";
$szLoaderPassword = "set";# THIS MUST BE SET
$nConfig = 1;# leave this line as last[/quote]

This is the Config.pl - will the commenting be a problem?
Link to comment
https://forums.phpfreaks.com/topic/4052-including-perl-into-php/#findComment-14088
Share on other sites

I wanted to avoid having the <?php ?> bits because this config.pl file is being used in other Perl scripts - I just wanted to be able to use these settings without having to restate them, and also pass on my PHP file to others who use the original program to without having them to reenter their details.

I'll keep thinking...
Link to comment
https://forums.phpfreaks.com/topic/4052-including-perl-into-php/#findComment-14108
Share on other sites

[!--quoteo(post=351596:date=Mar 4 2006, 10:15 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 4 2006, 10:15 AM) [snapback]351596[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Try this:
[code]<?php
$config = file('config.pl');
foreach($config as $line) {
    if (substr($line,0,1) != '#')
        eval($line);
}
?>[/code]

You really don't need the "if test".

Ken
[/quote]

Brilliant! I'm going to save that for future use!

[div align=\"center\"][img src=\"http://www.yamahafz1oa.com/forum/images/smilies/worship.gif\" border=\"0\" alt=\"IPB Image\" /][/div]
Link to comment
https://forums.phpfreaks.com/topic/4052-including-perl-into-php/#findComment-14197
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.