Ok, I studied the code some more and tested and tried and realized the < and > were reversed. This is what I've got now and it seems to work and I think I get it:
while ( my $html_file = $rule->match ) {
rename($html_file, "$html_file.bak") or die;
open(my $fh_in, '<', "$html_file.bak") or die;
open(my $fh_out, '>', $html_file) or die;
while (<$fh_in>) {
my @lines = <$fh_in>;
for (@lines) {
#replace <!--#include virtual="[document path]"-->
#with <?php include($_SERVER['DOCUMENT_ROOT'].'[document p
+ath]'); ?>
if (s/<!--#include virtual="(.*)"-->/<?php include(\$\
+_SERVER['DOCUMENT_ROOT'].'$1');?>/){
my $result = $1;
#print the file changed and the document path for the
+ included file
print OUTFILE "$html_file: $result\n";
}
print $fh_out $_;
}
close($fh_in);
close($fh_out);
}
I learn more and more about less and less until eventually I know everything about nothing.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.