"...no way of knowing if & where my search string will be split at new line "\n"...i try to load the whole file into a string and then do a pattern match"
I'm unsure if i understood your specs right but perhaps you want to do something like this:
use strict; use warnings; use feature qw(say); my $file = q(big.txt); my $size = -s( $file); my $pattern = qr((y+)(?:\n*)(y*)); open my $fh, '<', $file or die $!; read( $fh, my $data, $size ); close $fh; while( $data =~ m/$pattern/g ) { say qq($1$2); } __END__ # data like this: xyyyyyxxxx xxxxxxxxxx xxxxxxxxyy yyyxxxxxxx xxxxxxxxxx xxxxxxyyyy yxxxxxxxxx xxxxxxxxxx xxxxxyyyyy xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx # small version ;-) Desktop\monks>1129652.pl yyyyy yyyyy yyyyy yyyyy
The example runs on a 350MB file on XP 32bit with 2 GByte RAM in ~1s
Just an idea.
Regards, Karl
P.S.: If i use File::Map i get Out of Memory!
«The Crux of the Biscuit is the Apostrophe»
In reply to Re: Out of memory
by karlgoethebier
in thread Out of memory
by sandy105
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |