Dax Mickelson wrote: > I am having problems matching ALL possible matches of a string against > another (very large) string. I am doing something like: @LargeArray = > ($HugeString =~ m/$Head......../ig); Where $Head is an 8 character > string. (Basically I want to get all 16 character long substrings out of > $HugeString where the first 8 characters match $Head.) > > My problem comes about when (for example) I want to match a 16 character > string that starts with AAAAAAAA. Suppose $HugeString=AAAAAAAAAASDFGHJKL > and $Head=AAAAAAAA I want @LargeArray[0]=AAAAAAAAAASDFGHJ, > @LargeArray[1]=AAAAAAAAASDFGHJK, and @LargeArray[2]=AAAAAAAASDFGHJKL > > Right now I would only get @LargeArray[0]=AAAAAAAAAASDFGHJ > > What am I doing wrong? How do I get all matches?
The expression you are using should do what you want: $ perl -le' $HugeString = q/AAAbcdefgAAAhijklmnAAAopqrstAAAuvwxyz/; $Head = q/AAA/; @LargeArray = ( $HugeString =~ /$Head..../ig ); print for @LargeArray; ' AAAbcde AAAhijk AAAopqr AAAuvwx Perhaps there is only one occurrence of 'AAAAAAAAAASDFGHJ' in @LargeArray? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>