title: Retaining captures with the Perl substitution operator
body: <p>Can someone explain why the following code...</p>
  
  <pre><code>#!/opt/local/bin/perl
  use strict;
  use warnings;
  
  my $string;
  
  $string = "\t\t\tEntry";
  print "String: &gt;$string&lt;\n";
  
  $string =~ s/^(\t*)//gi;
  
  print "\$1: &gt;$1&lt;\n";
  print "String: &gt;$string&lt;\n";
  print "\n";
  
  $string = "\t\t\tEntry";
  
  $string =~ s/^(\t*)([^\t]+)/$2/gi;
  
  print "\$1: &gt;$1&lt;\n";
  print "String: &gt;$string&lt;\n";
  print "\n";
  
  exit 0;
  </code></pre>
  
  <p>...produces the following output...</p>
  
  <pre><code>String: &gt;           Entry&lt;
  Use of uninitialized value in concatenation (.) or string at ~/sandbox.pl line 12.
  $1: &gt;&lt;
  String: &gt;Entry&lt;
  
  $1: &gt;           &lt;
  String: &gt;Entry&lt;
  </code></pre>
  
  <p>...or more directly: Why is the matched value in the first substitution not retained in $1?</p>