Dear monks, With reference to the query "sorting and other problems in hash" posted by me last week, i have several doubts. As per the corrections given by you all, and after thoroughly understanding each and every line of the code, i tried to solve the problem. Ofcourse i did get the results only for the sample file and not for the original file. The reason being that the original file is 8GB in size, i doubt if this is the right approach. Just to load the file and count the lines in it using a while, it takes 1 minute. Then why is the following program takes forever, but not print the output at all? Please help me solve this problem. I need to process the 8 gig of data by any means :(
#!/usr/bin/perl use strict; use warnings; if ( scalar @ARGV < 2 ) { die("Usage:\n\t$0 file1 file2\n\n"); } my %data; my $fn = $ARGV[0]; { my $sequence; open DF, $fn or die $!; while ( my $line = <DF> ) { chomp $line; next if $line =~ m/^\s*$/; if ( substr( $line, 0, 1 ) eq '>' ) { ( $sequence, undef ) = split /\s+/, $line; } else { @{ $data{$sequence} } = split /\s+/, $line; } } close DF; } $fn = $ARGV[1]; { my $sequence; my $side; my $len; open DF, $fn or die $!; while ( my $line = <DF> ) { chomp $line; next if $line =~ m/^\s*$/; if ( substr( $line, 0, 1 ) eq '>' ) { ( $sequence, $side, undef, $len ) = split /(?:_|=|\s)+/, $line; if ( defined @{ $data{$sequence} } ) { my @range = ( 0, $len - 1 ); if ( $side ne "left" ) { @range = ( -1 * $len, -1 ); } print $line, "\n"; print join( ' ', @{ $data{$sequence} } [ $range[0] .. $range[1] ] ), "\n"; } else { warn "No data read from " . $ARGV[0] . " for sequence $sequence\n"; } } else { print join( " ", split //, $line ), "\n"; } } close DF; }

In reply to When the input file is huge !!! by sugar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.