in reply to Omitted subroutine arguments

Hello tel2.

In perl function calls, the caller passes an array to the function, which the function sees as the @_ array. The convention is to treat the members of the array as positional arguments.

The reason that omitted arguments are skipped is because perl collapses multiple commas into one when building the array of arguments to pass to the function.

There are three ways you handle optional arguments.

  1. You can order the arguments so the optional ones appear after any required ones.
  2. You can pass in '' or undef for any omitted arguments
  3. You can pass the arguments as a hash, or get the fuction to treat it's arguments as a hash.

You will see the last method (arguments as a hash) is quite common on a lot of CPAN modules. It is very powerful, but it does require the function caller to name all the arguments. This is often seen as a good thing as it makes code self documenting.