in reply to character-by-character in a huge file
Just an idea, I'm not sure whether you can use it.
If you make a copy of a large string you've read, the two copies will have separate pos-itions, thus, you can traverse both with regexps without the need for substr'ing it.
For example:
$string1= "hello, world\n"; $string2= $string1; pos($string1)= 4; whil +e ($string1=~/(.)/gs) {$win_right= $1; $string2=~/(.)/gs; $win_left= +$1; print " "x$n++, "$win_left...$win_right\n"}
prints:
h...o e..., l... l...w o...o ,...r ...l w...d o...
This will of course have difficulties on what to do at the boundary of two blocks you've read.
Update: spelling. Whether, whether, whether, whether, I'll have to learn this eventually.
|
|---|