in reply to Regexp string concat

First - doesn't BioPerl have a few functions that will do this?

As for code ... you still don't have all the requirements laid out yet. Specifically:

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.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

Replies are listed 'Best First'.
Re^2: Regexp string concat
by Murcia (Monk) on Jun 14, 2004 at 17:28 UTC
    • 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
      Heh. Your requirements seemingly contract each other. Specifically, you state that @new_query = @query if a value in @query isn't matched. However, you say that if something isn't matched and something else is matched twice, remove the double. But, you say that there can never be a double match.

      In other words, it doesn't sound like you can explain the requirements to a teddybear. I would spend some time with pencil and paper before going much further. Then, when you have pencil and paper down, convert those into test cases before writing any code.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested