PDA

View Full Version : Calling external header/footer files for a script



Carole
January 27th, 2001, 11:13
Hi,

what would you use to call an external file into a cgi script? I'm new to perl, but know enough to add modifications (hacks) and to change the layout around, but not sure about the language itself. I currently have my header/footer called from the script like:

$config{'header'} = <<EOF (header here) EOF

but that's a lot of html in an already huge file, so I want it to be called from another file, sort of like how you'd use:

<?include('header.html')?>

with a regular html file and php. It's probably simple, but I don't know a lot of CGI... any help?

Hobbes
January 27th, 2001, 15:32
Put your header into a separate file.




open(HEADER_FILE, "/path/to/headerfile");
@the_header = <HEADER_FILE>;
close (HEADER_FILE);



Now, wherever you want to put your header, just include it in your html or say



print "@the_header";



Tadaa! :D ...instant header addition.

Carole
January 28th, 2001, 08:54
Thanks, it worked after I added my @the_header; above it. :)