mwhiting has asked for the wisdom of the Perl Monks concerning the following question:
Hello
I need a short Perl subroutine that will recursively change the file paths in an HTML file to new file paths.
My HTML pages are designed to normally call graphics & server-side includes, etc from subfolders (as usual). But I have a perl program that needs to open, read the lines of one these html pages and output it as the output of the perl program.
The catch then, is that the references in the HTML are all wrong (images, links, server side includes, etc), since the Perl operates from the usual /cgi-bin folder, not from the usual HTML folder. The file structure is very standard, such as follows:
public_html
/cgi-bin
/images
/stylesheets
Further to that, the file references in the related SSI files in /stylesheets will be all wrong too.
I'm sure I've seen references in places to short scripts that will do this, and I'm looking to pick one of them up instead of writing it myself. In general it just needs to read an .html file line by line, try to match a text fragment & add in the "../" text. But it also needs to work recursively, identifying and opening the SSI's, and making the same subsitutions on them. I suppose this is the complicating factor that is making me look for a script - the reading and subsituting itself is straightforward.
Does anyone know of an existing script that will do this?
Alternatively, is there a different way to make this work? The real problem is that the server is working with /cgi-bin as the default directory, instead of the public_html folder above it, as it would with any regular websurfing.
Thank you so much.
|
|---|