<div>Hi, </div><div><br></div><div>I want to work on the strings that I find in the input, then output the processed content. </div><div>I'm wondering what's the elegant way to do it. </div><div><br></div><div>IIRC, it can be done with something like this</div>
<div><br></div><div>perl -ne 'print $2 . ", ". $1. "\n" while(/.../)'</div><div><br></div><div>But I really can't work out the rest now. </div><div>Please help. </div><div><br></div><div>Here is an example that you can work on. Given the following input, </div>
<div>I want to output, "<last-name>, <first-name>" on each line. </div><div>I.e., the output would be:</div><div><br></div><div>Franklin, Benjamin</div><div>Melville, Herman</div><div><br></div><div>
Thanks</div><div><br></div><div><div> <bookstore></div><div> <book genre="autobiography"></div><div> <title>The Autobiography of Benjamin Franklin</title></div><div> <author></div>
<div> <first-name>Benjamin</first-name></div><div> <last-name></div><div><span class="Apple-tab-span" style="white-space:pre"> </span> Franklin</last-name></div><div> </author></div>
<div> <price>8.99</price></div><div> </book></div><div> <book genre="novel"></div><div> <title>The Confidence Man</title></div><div> <author></div>
<div> <first-name></div><div><span class="Apple-tab-span" style="white-space:pre"> </span> Herman</div><div> </first-name></div><div> <last-name>Melville</last-name></div>
<div> </author></div><div> <price>11.99</price></div><div> </book></div><div>. . . </div></div><div><br></div>