My first guess is that '.' being a metacharacter u would need to escape it somehow.
something like this: foreach my $filter_key(@FFW) { $filter_key = quotemeta($filter_key); .... } -Sharad -----Original Message----- From: LI NGOK LAM [mailto:[EMAIL PROTECTED] Sent: Sunday, June 29, 2003 3:52 PM To: [EMAIL PROTECTED] Subject: Regex or Looping problem ? <snipped some annoying code> foreach my $result(@filelist) # a script snipped was given a file list { chomp ($result); my $com_result = $result; $com_result =~ s/^$root//; # $root was a defined var, where using to target the below filter focus # on the rest of parameter besides from the common root. my $skip_this = 0; if (@FFW) # FFW stands for Filter File With { foreach my $filter_key (@FFW) { $skip_this = 1 if ($com_result =~ /$filter_key/i); last if $skip_this; } } next if $skip_this; my $skip_this = 0; if (@FFO) # FFO stands for Filter files without { foreach my $filter_key (@FFO) { $skip_this = 1 if ($com_result !~ /$filter_key/i); last if $skip_this; } } next if $skip_this; push @ret, $result if ($result); } <snipped rest of code> The problem is if I give @FFW or @FFO a values like ('.txt', '.doc') the regex won't take care of the '.', I have try to modify like : $com_result =~ /$->{filter_key}/i I then get my job done with a new script, but unable to done the job when back to this script. So I wonder if there is something wrong with the 'next' statement . Anyway, I just can't figure out what's going wrong, any pointers ? Thanks