[tpm] find, manipulate, then output
James E Keenan
jkeen at verizon.net
Mon May 28 07:52:17 PDT 2012
On 5/28/12 9:59 AM, Antonio Sun wrote:
> I want to work on the strings that I find in the input, then output the
> processed content.
> I'm wondering what's the elegant way to do it.
> IIRC, it can be done with something like this
> perl -ne 'print $2 . ", ". $1. "\n" while(/.../)'
> But I really can't work out the rest now.
> Please help.
> Here is an example that you can work on. Given the following input,
> I want to output, "<last-name>, <first-name>" on each line.
> I.e., the output would be:
> Franklin, Benjamin
> Melville, Herman
> <book genre="autobiography">
> <title>The Autobiography of Benjamin Franklin</title>
It looks like you are trying to roll your own XML parser. Why?
More information about the toronto-pm