Can anyone explain why when the following matches the if, the second lines 'global' modifier doesn't seem to be global but picks up from where the first match in the 'if' statement left off. I've been able to get it working by putting the $file into a separate variable, but in a large script this seems very inefficient use of memory and creates a lot of extra code. Thanks for any help.
if ($file =~ m/(out of office|auto reply)/i){ @auto_reply = $file =~ m/(findthis|findthat)/ig; for (@auto_reply){ $auto_reply = $auto_reply . "\"" . $_ . "\" "; } } $file_temp = $file; if ($file =~ m/(out of office|auto reply)/i){ @auto_reply = $file_temp =~ m/(findthis|findthat)/ig; for (@auto_reply){ $auto_reply = $auto_reply . "\"" . $_ . "\" "; } }