title: using array elements for pattern matching in perl
body: <p>A newbie to Perl and regexes without saying, I am trying to use elements in an array in a perl regex. Here is the snippet</p>
  
  <pre><code>my $temp  = $line =~ s/somestring[^\n]*$_// for @myarray;
  </code></pre>
  
  <p>If I hard code the string instead of $_ it works fine. Also $_ prints the string fine in isolation. So what am I doing wrong? Even the expanded version of using a for loop doesn't yield a match.</p>
  
  <p>P.S Just to clarify the array has just one element and I know it matches the line.</p>