
BillKSmith
Veteran
Oct 29, 2013, 7:22 AM
Post #2 of 4
(1643 views)
|
Re: [huskysv] Text file manipulation with perl
[In reply to]
|
Can't Post
|
|
There are many ways to do this in Perl. The choice among them depends upon many factors which you did not tell us. How long are the files? Are the <section1> and </section1> tags always on the same line? Is Text2.txt an HTML document? Is it a template that never changes? One approach that should always work is to slurp Text1 into a single string $string1. Slurp Text2 into $string2. Use a regular expression to replace the gap in $string1 with the contents of $string2. Use positive lookahead and positive lookbehind assertions to match the tags, but not include them in the matched text. (Refer to documentation on extended regular expressions) Good Luck, Bill
|