in reply to Re: String manipulation in a document
in thread Grep a particular text
Dear sir, i am new to perl, and i need to cleanup my .tex file.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: String manipulation in a document
by GrandFather (Saint) on Jul 10, 2019 at 06:19 UTC | |
That is implied, but what are you expecting from us? We are happy to help with coding issues, but we are not usually a code writing service. If you show that you have made some effort we can help you go the next step. If you make no effort then probably neither will we.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
| [reply] |
by ponni (Novice) on Jul 11, 2019 at 06:49 UTC | |
Dear All, i have created the below script working fine to extract the query text and store in a variable. After that, i need to place the values after two carriage returns. I don't know how to place the query values after two carriage return. Kindly suggest friends!
| [reply] [d/l] |
by haukex (Archbishop) on Jul 11, 2019 at 15:50 UTC | |
Thank you for showing your code. To begin, several recommendations: Now moving on to the question of how to search and replace text. First of all, reading from input files and writing to output files is described in "Files and I/O" in perlintro - I would recommend reading the whole document, since it's not very long and it gives a good overview of Perl. As for the algorithm, there are several general approaches I'd consider: In the following, I'm using a combination of the third and fourth points, but note that this code makes quite a few assumptions about your input file format, which you haven't shown a lot of. In your real script, you'd have to replace DATA with the filehandle you opened.
Output:
I'm really not sure how you choose the insertion point for the \qr{} - in the original question, it seems you wanted it inserted after the fourth word in the paragraph, while in this example, it looks like you wanted it inserted after the second word. | [reply] [d/l] [select] |