<br><div class="gmail_quote">On Mon, May 28, 2012 at 10:52 AM, James E Keenan <span dir="ltr"><<a href="mailto:jkeen@verizon.net" target="_blank">jkeen@verizon.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 5/28/12 9:59 AM, Antonio Sun wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I want to work on the strings that I find in the input, then output the<br>
processed content.<br>
I'm wondering what's the elegant way to do it.<br>
<br>
IIRC, it can be done with something like this<br>
<br>
perl -ne 'print $2 . ", ". $1. "\n" while(/.../)'<br>
<br>
But I really can't work out the rest now.<br>
Please help.<br>
<br>
Here is an example that you can work on. Given the following input,<br>
I want to output, "<last-name>, <first-name>" on each line.<br>
I.e., the output would be:<br>
<br>
Franklin, Benjamin<br>
Melville, Herman<br>
<br>
Thanks<br>
<br>
<bookstore><br>
<book genre="autobiography"><br>
<title>The Autobiography of Benjamin Franklin</title><br>
<author><br>
<first-name>Benjamin</first-<u></u>name><br>
<last-name><br>
   Franklin</last-name><br>
</author><br>
</blockquote>
<br></div>
It looks like you are trying to roll your own XML parser.  Why?<br></blockquote><div><br></div>Thank you James for you reply. <div><br></div><div>I am fully aware of Perl's XML parser and XPATH handling, and I admit that it'll be much easier using the XPATH. However, my question was regarding working on the strings found and output the processed content, the Perl way. The enclosed XML was just an example. It can well be anything than XML. </div>
<div><br></div><div>Thanks</div><div><br></div><div><br></div></div>