hi monks, i have 2 files, i need to extract some data from one file based on another file. the data file is around 1GB. Since, its too big to read line by line, i got this idea to read it at their positions. I used tell and seek functions. But i have problems in getting the desired output. check out my code.
file1: SID834.56 AGAAGTCGTACGATCA SID164.26 AGTCGATCATTATATATTCGCTAG SID4.56 AGCTAGCGATCGATCCCCCCCCCCCCCCCC SID5764.12 CGATCGATC SID564.12 ACGAATATGATAC file2: cluster number 1: (reads count:2) SID834.56 SID564.12 cluster number 2: (reads count:2) SID164.26 SID5764.12 cluster number 3: (reads count:1) SID4.56 code: #!/usr/bin/perl -w use strict; use warnings; open(FH1,$ARGV[0]) or die "can not open\n"; open(FH2,$ARGV[1]) or die "can not open\n"; my @indx; while(<FH1>){ my ($id,$seq)=split("\t",$_); push(@indx, "$id\t".tell FH1); } while(<FH2>){ if($_=~m/^clus/){ my $clushead=$_; print "\n$clushead"; } else{ $_=~s/\t//g;$_=~s/\n//g; my $tes=$_; my @hit=grep(/$tes/,@indx); my $sca="@hit"; my ($id1,$pos)=split("\t",$sca); print sysseek (FH1,$pos,0),"\n" or die "seek:$!"; } } desired results: cluster number 1: (reads count:2) SID834.56 AGAAGTCGTACGATCA SID564.12 ACGAATATGATAC cluster number 2: (reads count:2) SID164.26 AGTCGATCATTATATATTCGCTAG SID5764.12 CGATCGATC cluster number 3: (reads count:1) SID4.56 AGCTAGCGATCGATCCCCCCCCCCCCCCCC results which i get now: cluster number 1: (reads count:2) 27 146 cluster number 2: (reads count:2) 62 122 cluster number 3: (reads count:1) 101
why is the seek function not fetching the content but the position? thanks !!!

In reply to seeking help for seek function by pearly

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.