There's more than one way to do things | |
PerlMonks |
How to search and replace text characters in a perl scriptby thetekguy (Initiate) |
on May 19, 2016 at 21:21 UTC ( [id://1163536]=perlquestion: print w/replies, xml ) | Need Help?? |
thetekguy has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Gurus! For someone more seasoned in perl coding I'm sure this is trivial, but I am a complete noob.
I have a text file that requires post-processing to remove lines matching certain control command lines, as well as pre-pend characters and remove characters from other lines.
My existing script works to remove lines that match certain control commands- G10, G11, G92, M190, but I am finding it very hard to figure out how to search/replace characters within each line without overwriting the whole line. The two strings I need to search and replace on a line by line basis are: 1) search for G1 ZNN.NNN where N is a number and . is a decimal, and replace with G1 Z-NN.NNN, retaining remainder of text on line 2) search for EN.NNNNN where N is a number and . is a decimal, and replace with null, retaining remainder of text on line. My existing code is: Sample Data: Expected Data
Back to
Seekers of Perl Wisdom
|
|