Using Perl to create PHP. I love it! :)
It's not that you're "not doing that part right".
It's simply that you're "not doing that part".
You never write out your changes.
while ( my $html_file = $rule->match ) { # Change file in-place. local @ARGV = $html_file; local $^I = '.bak'; # Or '' to avoid making backups. while (<>) { ... # Keep (possibly edited) line print; } }
If you want something less magical,
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>) { ... # Keep (possibly edited) line print $fh_in $_; } }
In reply to Re: modify file in place in script? Regex for changing includes from SSI to PHP
by ikegami
in thread modify file in place in script? Regex for changing includes from SSI to PHP
by hmbscully
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |