title: Perl regexp matching for strings with special characters
body: <p>I have list of substrings which I need to match within a list of URL strings. The substrings have special characters like '|', '*', '-', '+' etc. If the URL strings contains that substring I need to do some operation. But for now lets just say I will print "TRUE" in the console. </p>
  
  <p>I did this by first reading from the list of substrings and putting it into a hash. I then tried to perform a simple Regexp match of the entire list for each URL until a match is found. The code is something like this.</p>
  
  <pre><code>open my $ADS, '&lt;', $ad_file or die "can't open $ad_file";
  
  while(&lt;$ADS&gt;) {
          chomp;
  
          $ads_list_hash{$lines} = $_;
          $lines ++;
   }  
  
  close $ADS;
  
  open my $IN, '&lt;', $inputfile or die "can't open $inputfile";      
  my $first_line = &lt;$IN&gt;;
  
  while(&lt;$IN&gt;) {      
         chomp;       
  
         my @hhfile = split /,/;       
         for my $count (0 .. $lines) {
  
              if($hhfile[9] =~ /$ads_list_hash{$count}/) {
                  print "$hhfile[9]\t$ads_list_hash{$count}\n";
  
                  print "TRUE !\n";
                  last;
              }
         }
  
   }
  
   close $IN;
  </code></pre>
  
  <p>The problem is that the substrings have a lot of special characters which is causing errors in the match <code>$hhfile[9] =~ /$ads_list_hash{$count}/</code>. Few examples are;</p>
  
  <pre><code>+adverts/
  .to/ad.php|
  /addyn|*|adtech;
  </code></pre>
  
  <p>I get an error in lines like these which basically says "Quantifier follows nothing in regexp". Do I need to chanhge something in the regexp matching syntax to avoid these?</p>