Perl-Sensitive Sunglasses | |
PerlMonks |
Re: How to write at immediate next line of detecting a particular patternby Random_Walk (Prior) |
on Jan 26, 2014 at 10:29 UTC ( [id://1072122]=note: print w/replies, xml ) | Need Help?? |
You will read your file line at a time, and write the results to a new file. When you hit your pattern in the input stream, write your 200+line variable. Once this is done you can contiue reading and adding the rest of the original file, either line at a time, or by undefining the input field seperator: $/, as one block. Finally copy the new output file over the original As the tag <TARGET> looks rather like an XML or HTML like thing, perhaps you should look at proper *ML parsers, to acheive your aim more reliably When you have some code do post it, and we will be glad to help further
PS What will happen if TARGET tag is not on the end of a line? Cheers,
Pereant, qui ante nos nostra dixerunt!
In Section
Seekers of Perl Wisdom
|
|