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.
- You can order the arguments so the optional ones appear after any required ones.
- You can pass in '' or undef for any omitted arguments
- 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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.