First - doesn't BioPerl have a few functions that will do this?
I don't think so.
As for code ... you still don't have all the requirements laid out yet. Specifically:
* Do the matches have to be in the order specified? For example, what should @new_query contain if $string = 'EICHENLEBAUMSCHU'?
@new_query = qw( EIC, LEBAUMSCHU);
* What happens if something in @query isn't there? For example, $string = 'XXX'.
@new_query = @query
* What happens if there is more than one match? For example, $string = 'EICBAUMEIC'.
will not be the case
* What happens if something isn't there and there's two matches on something else?
remove double
* What happens if one element in @query fits into another element? For example, @query = qw( BAUM AU ).
@new_query = qw(BAUM)
* What happens if there are two possible solutions? For example, $string = 'BAABAB' and @query = qw( AA BA ).
will not be the case
I'm sure there are other possibilities that I didn't think of in the first five minutes of looking at the problem. Remember - if you can't explain the problem to a teddy bear, you can't explain the problem to a computer.
>thanks for good comments
Murcia
Snippets of code should be wrapped in
<code> tags not<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).