The stupid question is the question not asked | |
PerlMonks |
Re: Possible to have regexes act on file directly (not in memory)by RichardK (Parson) |
on May 03, 2014 at 12:54 UTC ( [id://1084888]=note: print w/replies, xml ) | Need Help?? |
Is it possible to let a regular expression act directly on a file *without* reading any part of the file to memory? No, a cpu can only see data in memory, so to process a file stored on disk you have to read some of it into memory. However, you could write a streaming parser that reads the file one byte at a time, backtracking might be somewhat costly but it will depend on the sort of patterns you want to match. Have a look at streaming XML parsers for ideas how you might go about this.
In Section
Seekers of Perl Wisdom
|
|