title: Perl: Empty $1 regex value when matching?
body: <p>Readers, </p>
  
  <p>I have the following regex problem: </p>
  
  <p><strong>code</strong></p>
  
  <pre><code> #!/usr/bin/perl -w
  use 5.010;
  use warnings;
  
  my $filename = 'input.txt';
  open my $FILE, "&lt;", $filename or die $!;
  
  while (my $row = &lt;$FILE&gt;)
  {                   # take one input line at a time
      chomp $row;
      if ($row =~ /\b\w*a\b/)
      {
         print "Matched: |$`&lt;$&amp;&gt;$'|\n";  # the special match vars
         print "\$1 contains '$1' \n";
      }
      else
      {
         #print "No match: |$row|\n";
      }
  }
  </code></pre>
  
  <h2>input.txt</h2>
  
  <pre><code>I like wilma. 
  this line does not match
  </code></pre>
  
  <h2>output</h2>
  
  <pre><code>Matched: |I like &lt;wilma&gt;|
  Use of uninitialized value $1 in concatenation (.) or string at ./derp.pl line 14, &lt;$FILE&gt; line 22.
  $1 contains ''
  </code></pre>
  
  <p>I am totally confused. If it is matching and I am checking things in a conditional. Why am I getting an empty result for $1? This isn't supposed to be happening. What am I doing wrong? How can I get <code>'wilma'</code> to be in $1? </p>
  
  <p>I looked <a href="https://stackoverflow.com/questions/16286318/empty-1-and-2-values-regex-perl">here</a> but this didn't help because I am getting a "match". </p>