[tpm] find, manipulate, then output

Antonio Sun antoniosun at lavabit.com
Mon May 28 06:59:15 PDT 2012


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>
     <book genre="novel">
       <title>The Confidence Man</title>
. . .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20120528/aecc83da/attachment.html>

More information about the toronto-pm mailing list