in reply to Re: retrieving in the correct order
in thread retrieving in the correct order

Hi VSarkiss, Thanks for your solution but I can't get it to work! Maybe it's becuase my first array is quite big (~1000 sequences). But wouldn't this just slow it down? Thanks

Replies are listed 'Best First'.
Re^3: retrieving in the correct order
by VSarkiss (Monsignor) on Dec 16, 2004 at 20:47 UTC

    Well, some detail on what went wrong would help....

    When I tried it against the sample data in your original post, I noticed two things:

    1. You're testing for gi| at the beginning of the line, but your @array1 values start with >gi|. I had to remove the >; you'll have to either fix the $key = line to match your data, or fix the data to match your test...
    2. You're populating a single element in array2. If you want each number to be an element of the array, you need to use qw(...), not qq(...).

    If these are both copy-and-paste artifacts, pleave provide more detail on what the error is.

      Sorry,

      I should have been more specific.

      The two problems that you noticed are not problems in my program, just in the example I gave in my question.

      With the code that you posted I don't get any error - but I don't get any output either ;-( The $key is definately picking up values (e.g. gi|14028145 |) so I think the problem is with substr. Also, the values of @array2 are present in @array1 as I have checked.

      Hope you can help.

      Thanks!

Re^3: retrieving in the correct order
by insaniac (Friar) on Dec 16, 2004 at 21:51 UTC
    hey, check my code below, i tested it with a file with 3000 lines in it. time cat gen.txt | perl -w gen.pl says:
    real 0m0.139s user 0m0.109s sys 0m0.000s

    if you're still looking for an answer...

    --
    to ask a question is a moment of shame
    to remain ignorant is a lifelong shame