[tpm] find, manipulate, then output
antoniosun at lavabit.com
Mon May 28 08:13:00 PDT 2012
On Mon, May 28, 2012 at 10:52 AM, James E Keenan <jkeen at verizon.net> wrote:
> 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?
Thank you James for you reply.
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the toronto-pm