Hi all, I am still new to perl and have to use it for a class assignment. I have a for loop inside another for loop, and I want the outer one to exit when the regular expression built in the inner loop matches a string. It will not exit, though, and just keeps running until its termination condition is reached, ignoring my "Last" keyword completely. I have pasted the two loops below; again, this is perl 5.1. for $i(2...25){ #build regexp by looping through @msg for $j(0...@msg-2){ #each itteration, add the next char to the regexp $r.=$msg[$j].'.{'.$i.'}'; #this searches for a char in the message, $i (period) number of characters, then the next char in the msg, and so on } #now that we have the regexp, match it to the string that is the file content to see if there is a match at this period if($txt=~m/$r/gi ){ #found the regexp, so print success and quit the loop print("Match found. Period: $i."); $found=1; } if($i==24 and $found==0){ #message will not be found, so tell the user print("Your message was not found in the file."); } $r=""; #reset $r for the next period to be built } The problem is that, even if the string is found once, the main loop keeps going and finds the string at all other periods instead of quitting. -- Have a great day, Alex My email is now: mehgcap@xxxxxxxxx __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind