Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:20:52+00:00 2026-05-29T10:20:52+00:00

I have a script that reads two csv files and compares them to find

  • 0

I have a script that reads two csv files and compares them to find out if an ID that appears in one also appears in the other. The error I am receiving is as follows:

Out of memory during “large” request for 67112960 bytes, total sbrk() is 348203008 bytes

And now for the code:

use strict;
use File::Basename;

my $DAT     = $ARGV[0];
my $OPT     = $ARGV[1];

my $beg_doc = $ARGV[2];
my $end_doc = $ARGV[3];

my $doc_counter  = 0;
my $page_counter = 0;
my %opt_beg_docs;
my %beg_docs;

my ($fname, $dir, $suffix) = fileparse($DAT, qr/\.[^.]*/);
my $outfile = $dir . $fname . "._IMGLOG";

open(OPT, "<$OPT");
    while(<OPT>){
        my @OPT_Line = split(/,/, $_);
        $beg_docs{@OPT_Line[0]} = "Y" if(@OPT_Line[3] eq "Y");
        $opt_beg_docs{@OPT_Line[0]} = "Y";
    }
close(OPT);
open(OUT, ">$outfile");
while((my $key, my $value) = each %opt_beg_docs){

    print OUT "$key\n";
}
close(OUT);

open(DAT, "<$DAT");

    readline(DAT); #skips header line
    while(<DAT>){

        $_ =~ s/\xFE//g;

        my @DAT_Line = split(/\x14/, $_);

        #gets the prefix and the range of the beg and end docs
        (my $pre = @DAT_Line[$beg_doc]) =~ s/[0-9]//g;
        (my $beg = @DAT_Line[$beg_doc]) =~ s/\D//g;
        (my $end = @DAT_Line[$end_doc]) =~ s/\D//g;

        #print OUT "BEGDOC: $beg ENDDOC: $end\n";

        foreach($beg .. $end){
            my $doc_id = $pre . $_;

            if($opt_beg_docs{$doc_id} ne "Y"){
                if($beg_docs{$doc_id} ne "Y"){
                    print OUT "$doc_id,DOCUMENT NOT FOUND IN OPT FILE\n";
                    $doc_counter++;
                } else {
                    print OUT "$doc_id,PAGE NOT FOUND IN OPT FILE\n";
                    $page_counter++;
                }
            }
        }
    }
close(DAT);
close(OUT);

print "Found $page_counter missing pages and $doc_counter missing document(s)";

Basically I get all the ID’s from the file I am checking against to see if the ID exists in. Then I loop over the and generate the ID’s for the other file, because they are presented as a range. Then I take the generated ID and check for it in the hash of ID’s.

Also forgot to note I am using Windows

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:20:52+00:00Added an answer on May 29, 2026 at 10:20 am

    I’m not sure if it’s the cause of your error, but inside your loop where you’re reading DAT, you probably want to replace this:

            (my $pre = @DAT_Line[$beg_doc]) =~ s/[0-9]//g;
    

    with this:

            (my $pre = $DAT_Line[$beg_doc]) =~ s/[0-9]//g;
    

    and same for the other two lines there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a shell script that reads the files in a particular directory. #!/bin/bash for
I have a Python script that reads through a text csv file and creates
I have a script in python that needs to read iso-8859-1 files and also
I have a python script that reads raw movie text files into an sqlite
I have a script that reads a form and puts some info into a
I have a written a script in PHP that reads from data from a
I am trying to write a simple Perl script that reads a *.csv, places
I have a Python script that reads a file (typically from optical media) marking
I have one PHP script that has to start a second script in the
There are two strings test_name that are compared in a VB script. They have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.