Hi guys
The server i am going to run the belowmentioned script has 64GB memory. I can only use maximum 80% memory load.
The perl script below is using Data:Dump to dump all the data.
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dump qw/dump/;
my %data;
foreach my $filename (qw/one.txt two.txt three.txt/) {
open( my $file, $filename )
or die "Unable to open $filename because $!\n";
while (<$file>) {
chomp;
my ( $chrX, $chrpos, $value1, $value2 ) = split(/\s+/);
$data{$chrX}->{$chrpos}->{'value1'} += $value1;
$data{$chrX}->{$chrpos}->{'value2'} += $value2;
} ## end while (<$file>)
} ## end foreach my $filename (qw/one.txt two.txt three.txt/)
print dump( \%data );
the text files are as below
one.txt
chromosome1 50000 12 20
chromosome2 20000 0 21
chromosome3 41444 9 2
chromosome4 21414 4 1
.
.
.
(there would be 5million lines of the above)
This applies to two.txt and three.txt as well, same format, same number of lines (approximately 5million)
I would like to know is this script able to run on the server without overloading?
Or is there any other better way of doing this without putting much load on the memory?
Cheers guys!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.