troubleshooting Question

How do I replace a block of text using regular expressions in Perl?

Avatar of jay28lee
jay28lee asked on
Scripting LanguagesPerlRegular Expressions
8 Comments2 Solutions357 ViewsLast Modified:
I have the following subroutine reading the content of a text file template

sub readfile {
   open(INFILE,"$_[0]");
   flock(INFILE,2);
   my @content=<INFILE>;
   flock(INFILE,8);
   close(INFILE);
   return @content;
}

Open in new window


The template contains block of content I would like to replace, from <!--tmpl_start--> to <!--tmpl_end--> where anything can possibly go in between.

It would be easy to use a foreach loop if they are on the same line.

How do I implement this if they're on different lines?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros