title: Pass array and scalar to a Perl subroutine
body: <blockquote>
    <p><strong>Possible Duplicate:</strong>
    <a href="https://stackoverflow.com/questions/10640982/how-do-pass-one-array-and-one-string-as-arguments-to-a-function">How do pass one array and one string as arguments to a function?</a></p>
  </blockquote>
  
  
  
  <p>I have a function, or subroutine, that takes in the first parameter as an array and the second parameter as a scalar. For example,</p>
  
  <pre><code>sub calc {
      my @array = $_[0];
      my $scalar = $_[1];
      print @array, $scalar;
  }
  </code></pre>
  
  <p>The problem is that the function is making the array equal to the first value of the array passed in, and the scalar to be the second value of the array passed in. When I want the first array to be the entire array, I do not need to make a deep copy of the array. For example,</p>
  
  <pre><code>my @array = ('51', 'M');
  my $scalar = 21;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>calc(@array, $scalar)
  </code></pre>
  
  <p>will print <code>51 M</code> when I want <code>51 M 21</code>.</p>