in reply to Re: search/replace very large file w/o linebreaks
in thread search/replace very large file w/o linebreaks
Alternatively, just do a while(<>) loop with the substitution and print inside, but run it twice with two different record lengths such that no multiples (less than the file size) of the two come within a distance of each other less than the length of the longest tag. Don't know quite how to go about calculating such numbers, though. Any number theoreticians here?use constant BLOCKLENGTH => 32768; # > length of any tag $\ = \BLOCKLENGTH; my $buffer = ''; while (!eof()) { $buffer .= <>; s/tag1/\n/g; s/tag2/\t/g; # leave BLOCKLENGTH chars in $buffer, # print however much comes before that print substr($buffer, 0, -BLOCKLENGTH, ''); }; # print whatever's left print $buffer;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: search/replace very large file w/o linebreaks
by nothingmuch (Priest) on Jan 09, 2004 at 11:37 UTC | |
by borisz (Canon) on Jan 09, 2004 at 11:48 UTC | |
by nothingmuch (Priest) on Jan 09, 2004 at 11:51 UTC | |
by ysth (Canon) on Jan 11, 2004 at 03:13 UTC | |
by nothingmuch (Priest) on Jan 11, 2004 at 13:22 UTC | |
by ysth (Canon) on Jan 11, 2004 at 17:39 UTC |