Gossamer Forum
Home : General : Perl Programming :

includes in cgi like php maybe

Quote Reply
includes in cgi like php maybe
Crazy

the majorit of files on my site are php and i came to a sudden conclusion before i edited the dbman script i downloaded. How through the cgi files do i include text files. Through out my site i use txt includes to simplify the links and content. Hope you guys know what im looking for here.



What is the cgi/perl include command that works like this:



<?php

include("blahblah.txt");

?>



is there a perl equivalent to this simple command?



To better help you understand what im doing let me explain. I want to change all of the info from the tables generated and fill it into a theme like my current website

putting the info generated in a middle content area. the only way i could figure is to hand edit everything and then use those include commands. help me if you can thanks.




go to our site at http://www.eqsanctum.com/oov and youll see what i mean

Last edited by:

sanctum: Oct 14, 2002, 5:25 AM
Quote Reply
Re: [sanctum] includes in cgi like php maybe In reply to
There isn't one really. You can create your own though:

Code:
sub include {
#---------------------------------------------------
# Pass in a file name to include.

my $file = shift or return;
my $path = '/full/path/to/includes';

open INC, "$path/$file" or return $!;
read INC, my $str, -s INC;
close INC;

return $str;
}

You'd then use something like this wherever you want your include to appear:

print include('this.txt');
Quote Reply
Re: [Paul] includes in cgi like php maybe In reply to
so under the " print qq |



<all html junk here>



i would add that where needed then?



then |;





so where exactly would i place the sub_html content then?
Quote Reply
Re: [sanctum] includes in cgi like php maybe In reply to
You can't put perl code inside strings (well you can but I won't go into it) so if you want it inside the print qq| | then you'd do:

my $include = include('this.txt');

print qq|

All your html stuff

$include

End of html stuff
|;

Last edited by:

Paul: Oct 14, 2002, 5:44 AM