title: How can I match start of the line or a character in Perl?
body: <p>For example, this is ok:</p>
  
  <pre><code>my $str = 'I am $name. \$escape';
  $str =~ s/[^\\]\K\$([a-z]+)/Bob/g;
  print $str; # 'I am Bob. \$escape';
  </code></pre>
  
  <p>But below is not what I was expected.</p>
  
  <pre><code>my $str = '$name';
  $str =~ s/[^\\]\K\$([a-z]+)/Bob/g;
  print $str; # '$name';
  </code></pre>
  
  <p>How can I correct this?</p>