title: Perl subroutine arguments
body: <p>I have been reading about Perl recently and am slightly perplexed about how Perl handles arguments passed to subroutines.</p>
  <p>In a language like Python, Java or PHP, a function definition takes the form (in pseudocode):</p>
  <pre class="lang-php prettyprint-override"><code>function myFunc(arg1, arg2) {
      // Do something with arg1 and arg2 here
  }
  </code></pre>
  <p>Yet in Perl it's just:</p>
  <pre><code>sub mySub {
      # @_ holds all arguments passed
  }
  </code></pre>
  <p>And as I understand it, that's the only way to do it.</p>
  <ul>
  <li><p>What if I want to restrict the caller to only pass two arguments?</p>
  </li>
  <li><p>Isn't this just Perl not allowing anything but variable-number arguments in other languages (i.e., Python, C, etc.)?</p>
  </li>
  <li><p>Wouldn't that become a problem at some point?</p>
  </li>
  <li><p>What about all the default argument-number checking in other languages? Would one have to do that explicitly in Perl? For instance</p>
  <pre><code>  sub a_sub {
        if (@_ == 2) {
            # Continue function
        }
        else {
            return false
        }
    }
  </code></pre>
  </li>
  </ul>