[Israel.pm] Sophisticated text processing tools

Gaal Yahas gaal at forum2.org
Sun Feb 8 05:59:02 PST 2004

On Sun, Feb 08, 2004 at 03:15:27PM +0200, Jason Elbaum wrote:
> 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?

Take a look at the pos function, and the \G regexp metacharacter.

But if you're doing source code analysis and you want it to be robust,
you really need a parser. (I hope you're not trying to parse Perl.)
Parse::RecDescent comes with a c grammar, if that's what you're after;
grammars for Java and C++ I'm sure are available online. In some cases
you'll get by with straight regexps but that's only if your source is
strictly formatted.

Good luck,

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list