title: How is it that chomp is able to change the value of a variable not passed by reference?
body: <p><code>chomp</code> seems to be able to change the value of a variable not passed by reference; that is, the syntax is <code>chomp $var</code> instead of <code>chomp \$var</code>.</p>
  
  <p>How is this possible?  How can I imitate this behavior in a function? </p>
  
  <p><code>chomp</code>:</p>
  
  <pre class="lang-perl prettyprint-override"><code>my $var="foo\n";
  chomp $var;
  print $var
  </code></pre>
  
  <p><code>mychomp</code>:</p>
  
  <pre class="lang-perl prettyprint-override"><code>my $var="foo\n";
  mychomp(\$var);
  print $var;
  
  sub mychomp {
    my $ref=shift;
    $$ref=~s/\s+$//;
  }
  </code></pre>