faozhi has asked for the wisdom of the Perl Monks concerning the following question:
the text files are as below#!/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 );
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Enquiry on memory usage
by BrowserUk (Patriarch) on May 06, 2009 at 14:06 UTC | |
by faozhi (Acolyte) on May 08, 2009 at 08:09 UTC | |
by BrowserUk (Patriarch) on May 08, 2009 at 09:17 UTC | |
by faozhi (Acolyte) on May 08, 2009 at 12:39 UTC | |
|
Re: Enquiry on memory usage
by citromatik (Curate) on May 06, 2009 at 12:23 UTC | |
|
Re: Enquiry on memory usage
by mikeraz (Friar) on May 06, 2009 at 12:46 UTC |