Larry Wissink wrote:
>
> We have a backup server that is missing records from the production
> server for a particular table. We know that it should have sequential
> records and that it is missing some records. We want to get a sense of
> the number of records missing. So, we know the problem started around
> the beginning of March at id 70,000,000 (rounded for convenience).
> Currently we are at 79,000,000. So, I dumped to a file all the ids
> between 70,000,000 and 79,000,000 (commas inserted here for
> readability). I need to figure out what numbers are missing. The way
> that seemed easiest to me was to create two arrays. One with every
> number between 70 and 79 million, the other with every number in our
> dump file. Then compare them as illustrated in the Perl Cookbook using
> a hash.
>
> The simple script I came up with works fine with a test file of just 10
> records.
>
> But, when I try to scale that to 9 million records, it doesn't work.
> This is probably because it is trying to do something like what db
> people call a cartesian join (every record against every record).
>
> So, does anybody have a suggestion for a better way to do it in Perl?
Something like this should work:
my $last = <FILE>;
while ( my $current = <FILE> ) {
for ( my $missing = $last + 1; $missing < $current; ++$missing ) {
print "$missing\n";
}
$last = $current;
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>