I believe in a scalar context m/../g remembers the position where it last matched and will start the next the search at that position the next time it is invoked. So, for example, it fails on "I'm here B" because it started the search where it last left off, after "test", and it doesn't find "test" in the rest of $line. It resets to the begining if it failed to find anything. Pretty neat. Hope that helps, George At 3:14 PM -0500 4/16/99, Muggli, Ricardo T. (CCC) wrote: >I'm having a problem that if I do a match on the same pattern in a row it >will not match on every other one. This is my test code. > >$line = "this is a test of a weird problem";print "A\n";if ($line =~ >m/test/g) { print "I'm here A\n";}print "B\n";if ($line =~ m/test/g) { >print "I'm here B\n";}print "C\n";if ($line =~ m/test/g) { print "I'm >here C\n";}print "D\n";if ($line =~ m/test/g) { print "I'm here >D\n";}print "E\n";if ($line =~ m/test/g) { print "I'm here E\n";}print >"F\n";if ($line =~ m/test/g) { print "I'm here F\n";}print "G\n";if >($line =~ m/test/g) { print "I'm here G\n";}print "H\n";if ($line =~ >m/test/g) { print "I'm here H\n";} > >The output I get is: >AI'm here ABCI'm here CDEI'm here EFGI'm here GH > >The output should be: >A >I'm here A >B >I'm here B >C >I'm here C >D >I'm here D >E >I'm here E >F >I'm here F >G >I'm here G >H >I'm here H > >thanks, >Ricardo Muggli > > > >===== Want to unsubscribe from this list? >===== Send mail with body "unsubscribe" to macperl-request@macperl.org ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org