Perl: the Markov chain saw | |
PerlMonks |
Script fails to insert text and appends it towards the end of file.by always_coys (Novice) |
on Nov 21, 2020 at 12:40 UTC ( [id://11123966]=perlquestion: print w/replies, xml ) | Need Help?? |
always_coys has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I am trying to automate the running of a finite element program using a Perl script. It requires me to copy a block of text (each line starting with the same keyword) and insert it to a second file, at a particular line number. There is text in the second file, before and after this line number. With help from the Monks, I was able to update my script. However, I am noticing that the script is simply appending to the output file, rather than inserting the block of text to the desired line number. The input file is given below. I am trying to copy the lines beginning with the keyword NODE and inserting it in the output file, at line number 37. Basically, I am trying to append to a section of the output file (to lines containing the same keyword). I have left sufficient space in the output file for inserting text from the input file.
The output file is given below.
My script below, should ideally place the block of text beginning with NODE from the input file, on line number 11 of the output file (i.e. just below another block of text that begins with NODE. However, my script is simply appending the text to the output file (after counting 11 lines from the end). Could the Monks please help me identify what went wrong?) Thanks a lot (always_coys).
Back to
Seekers of Perl Wisdom
|
|