in reply to Re: seeking help for seek function
in thread seeking help for seek function

i used readline function below seek, like this:
$buffer = readline( *FH1 ); print("$buffer");
but it still doesnt give the right sequence.

Replies are listed 'Best First'.
Re^3: seeking help for seek function
by ikegami (Patriarch) on Mar 25, 2010 at 07:50 UTC
    You use tell for SID834.56 when the file pointer is here:
    SID834.56 AGAAGTCGTACGATCA [*]SID164.26 AGTCGATCATTATATATTCGCTAG
    You want to use tell for SID834.56 when the file pointer is here:
    SID834.56 [*]AGAAGTCGTACGATCA SID164.26 AGTCGATCATTATATATTCGCTAG
    That's not easy to do, but it's easy and acceptable to use tell for SID834.56 when the file pointer is here:
    [*]SID834.56 AGAAGTCGTACGATCA SID164.26 AGTCGATCATTATATATTCGCTAG

    (i.e. before you read the line)

      i just noticed that. i want to use file pointer at the begining of everyline.but, when i use tell function, why does it point to the end of the line and not the begining?
      getting the correct position by using
      my @indx; my $pos = 0; while(<FH1>){ my ($id, $seq) = split /\t/; push(@indx, "$id\t$pos"); $pos = tell FH1; }
      thanks for that !!! trying to read the correct line now...
      i just noticed that. i want to use file pointer at the begining of everyline.but, when i use tell function, why does it point to the end of the line and not the begining?

        After you've read a line, the file pointer will naturally always be at the end of the line (= beginning of the next line). That is so because for every byte being read, the file pointer advances by one.

        Try this to get the correct positions:

        my @indx; my $pos = 0; while(<FH1>){ my ($id, $seq) = split /\t/; push(@indx, "$id\t$pos"); $pos = tell FH1; }