Help on Perl parsing file to locate and replace Include files in CGI app 
Author Message
 Help on Perl parsing file to locate and replace Include files in CGI app

Hi all,

I have a number of Perl CGI programs running on our Intranet.  To
enable our web designer to keep all our pages standard with the right
logos and headings and stuff, my programs all use HTML template files.
 For example, my program prints the first part of the template file
and then adds whatever it needs to programmatically for the particular
application, and then prints the remainder of the template file.  The
designer marks the insert location using particular comment tags.

This was all working fine - any changes by our designer were
immediately working on applications with no program changes, but now
our designer is doing a site redesign that encorporates a lot of SSI -
particularly include files.

I know that if I just output the HTML from the template files, the
server will not parse for SSI and so the pages aren't working.

I thought it should be possible to search the HTML templates myself
(perhaps using regular expressions?), locate any SSI includes, and
replace the references with the actual contents from the referenced
files, but I am having trouble getting my head around the specifics of
it.

Has anyone done this?  Can you post an example? Or point me to one
someplace on the web? I've done some searching but haven't found
anything.

Thanks,

Jennifer



Mon, 01 Mar 2004 17:24:56 GMT  
 Help on Perl parsing file to locate and replace Include files in CGI app

Quote:

>Hi all,

>I know that if I just output the HTML from the template files, the
>server will not parse for SSI and so the pages aren't working.

There are some modules on CPAN that allow you to process SSI tags from CGI
applications.  CGI::SSI and Apache::SSI are possible options for you.

You might also consider talking over the use of style sheets with the web
designer and going to something like Text::Template or Mason that can
allow both you and the web designer to collaborate more usefully.

As a third option you might consider "inverting" your model and use the SSI
exec tag to call out to perl code that returns the computed fragment of the
page.

As always TIMTOWTDI
chris
--
    This space intentionally left blank



Mon, 01 Mar 2004 20:01:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Perl / cgi / include file a la #include

2. Including my perl functions in one file in another perl script file

3. Including a perl file into another perl file???

4. Recursive include in parsed file

5. perl scripts tries to locate specific file, getting file not found

6. Help: h2ph and perl include files

7. including local file in .cgi

8. Could not locate a PPD file...PLEASE HELP!!!!

9. Question: list files including words from a word-listing file

10. Help with replacing of text (Code included)...

11. Processing of Postscript files with included EPS-file

 

 
Powered by phpBB® Forum Software