in reply to Re^4: write to Disk instead of RAM without using modules
in thread write to Disk instead of RAM without using modules

If I understand correctly, you need to load only the first file in memory (in your hash). Then you can read sequentially every other file one after the other and for, each record in such files, check if the record was in the first file, and add 1 to the value if it is there (and print anything to a new file if needed). After having read one file, remove the hash records which have not been updated. Then proceed the same way with the next file, and so on with all the other files.

At the end, you hash will contain only the records which have been found in every single file.

In brief, you only need to load the first file in memory, all the others can be read sequentially.

  • Comment on Re^5: write to Disk instead of RAM without using modules

Replies are listed 'Best First'.
Re^6: write to Disk instead of RAM without using modules
by Anonymous Monk on Oct 25, 2016 at 07:54 UTC
    I am unable to understand how to load first file in memory and sequentially read other files. can you please help me with my script or exemplify with a short script. Any help will be appreciated.

      The following code reads a file line by line:

      my $filename = 'some/filename.txt'; open my $fh, '<', $filename or die "Couldn't read '$filename': $!"; while (<$fh>) { ... }

      If you want to store information about a file, do so while reading it line by line.

        I need to open and compare multiple files and not open just one file. So I have to open files sequentially and compare. I am unable to get that through.