in reply to regexing my brain...
Note that there are many ways to fix this problem. By the way, you can drop the capture ( .. ) in your regexp too.#!/usr/local/bin/perl -w use strict; my $pagecode; { local $/; $pagecode = <DATA>; } my $content = "Roger"; print "before:\n---------\n$pagecode\n"; # fix 1 $pagecode =~ s/<!--BeginContent-->(?:.|\n)*<!--EndContent-->/<!--Begin +Content-->$content<!--EndContent-->/; # fix 2 $pagecode =~ s/<!--BeginPages-->.*<!--EndPages-->/<!--BeginPages--><!- +-EndPages-->/s; print "after:\n---------\n$pagecode\n"; __DATA__ <!--BeginContent-->Hello World! This is a comment line <!--EndContent--> <!--BeginPages-->Hello World! <!--EndPages-->
|
|---|