TheMartianGeek has asked for the wisdom of the Perl Monks concerning the following question:
But this only solves part of the problem. This takes into account that these blocks of data should not cross certain boundaries; in this case, they should not be split between groups of 0x8000 characters. (A block that goes from offset 0x7F70 to 0x8020 would count as two blocks.) There is, however, another factor involved: These blocks must not be part of a protected area marked off with a certain ASCII string.$/ = \0x8000; my @addrlist = (); while(<$fh>) { $block = $_; while ($block =~ m{(\x00+)}g) { unless(length($1) < $FreespaceSize) { my $t1 = length($1); my $t2 = pos($block) - length($1); push(@addrlist, $t2); push(@addrlist, $t1); } } } return @addrlist;
Here, there would be an 11-byte-long block at offset 0x03, a 9-byte-long block at offset 0x37, and a 12-byte-long block at offset 0x40. The 6-byte block of 00s at offset 0x18 do not count because the minimum qualifying length is 8, and the 9-byte block at offset 0x56 does not count because it is protected by the "74 75 76 77" tag. (And in the actual situation, the data protected by the tag could straddle a boundary!) The blocks at offsets 0x37 and 0x40 must be split up into two separate blocks rather than one 21-byte-long block because of the boundary between offsets 0x3F and 0x40. See what I'm getting at here?09 43 4A 00 00 00 00 00 00 00 00 00 00 00 FC B0 DD 12 46 33 73 7A 8B 01 00 00 00 00 00 00 98 40 34 3F 79 6D DC 2A 2B 35 FF 90 FA 60 66 58 5A 21 40 06 88 F2 11 EE 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 88 CC 02 A0 74 75 76 77 09 00 00 00 00 00 00 00 00 00 AA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding large blocks consisting of a single character (but within certain parameters...)
by BrowserUk (Patriarch) on Mar 07, 2011 at 09:32 UTC | |
by TheMartianGeek (Acolyte) on Mar 07, 2011 at 14:56 UTC | |
by BrowserUk (Patriarch) on Mar 07, 2011 at 16:27 UTC | |
by TheMartianGeek (Acolyte) on Mar 08, 2011 at 05:27 UTC | |
by BrowserUk (Patriarch) on Mar 08, 2011 at 05:53 UTC | |
|
Re: Finding large blocks consisting of a single character (but within certain parameters...)
by BrowserUk (Patriarch) on Mar 07, 2011 at 07:48 UTC |