[Israel.pm] Sophisticated text processing tools

Jason Elbaum Jason.Elbaum at motorola.com
Sun Feb 8 05:15:27 PST 2004


I have some complex text processing tasks I'd like to do with Perl, and 
I'm wondering whether there are any well-known techniques or modules 
which would help.

I'd like to make some automated modifications to source code files: read 
a file, make some changes, write it back under a modified name. However, 
the changes are complex, and I'm looking for a tool more flexible than 
regular expressions.

For example, I'd like to be able to 1) find the next place in the file 
which may need to be modified, 2) analyze the area around it to 
determine what to change and how,  3) make the changes, and then 4) 
continue scanning the file from that point.

I might be searching for a variable of a certain name or type, and then 
changing the code which uses it. But the code which uses it might appear 
a line or two before the variable name. So I want to find the point, 
then analyze the area around it.

Can regexps be made to return a string position indicator, or to start 
from a given string position? Should I read the file directly in chunks, 
keeping track of the file position? Are there other options I'm not 
thinking of?


Thanks,

Jason Elbaum




More information about the Perl mailing list