On 21/10/2011 11:31, Nathalie Conte wrote:
HI Rob,
Hello Nat Please keep your replies to the Perl beginners list, so that other people can both help and learn from the discussion. (It would also help if you could bottom-post your replies (put the response after the text you are quoting). It is the list standard, and helps to keep long threads comprehensible.)
I have ran your script and got this output GCAGTGGA 9 TCTGGCAG 8 ^TGGCAGTGGAGG 7 TCTGTCTG 2
That is incorrect, and I suspect that you still have the /g modifier on your regex. Without it I get GCAGTGGA 14 TCTGGCAG 8 ^TGGCAGTGGAGG 7 TCTGTCTG 2
thanks a lot for your input, some things were uncorrect as you mentionned because of the /g and the ^A|T|G|C I still don't understand why you say that /g in not necessary as I want my patterns to be complete, I though I needed the \g option in there. another quick thing, the next unless will go to the next line of the in file if not true?
/g finds all occurrences of the pattern in the target string. In list context it finds and returns them all at once, but in scalar context (which is how an if condition is evaluated) it finds them one at a time (that is why each match starts where the previous one left off). In this case you simply want to know whether or not the pattern appears in the string - you are not interested in where it matches or how many times - so /g is incorrect.
thanks again helping newbies :) Nat
That is what the list is here for. I am glad to help. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/