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

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)

Replies are listed 'Best First'.
Re^4: seeking help for seek function
by pearly (Initiate) on Mar 25, 2010 at 09:57 UTC
    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...
Re^4: seeking help for seek function
by Anonymous Monk on Mar 25, 2010 at 08:56 UTC
    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?
Re^4: seeking help for seek function
by pearly (Initiate) on Mar 25, 2010 at 09:01 UTC
    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; }