I guess you would reply that you ARE using prototypes, but I doubt you are using strict and warnings. If you were then you would get "Request::aaa() called too early to check prototype".
The @ prototype is pretty useless. It accepts a list (not just an array), a single scalar (since that is a single entry list), and even nothing, since an empty list is still a valid list.
Yes you need to use references for this:
use warnings;
use strict;
sub Request::aaa(\@\@);
#main.pl
my @a1 = qw (the quick brown fox);
my @a2 = qw (theres more than one way);
Request::aaa(@a1, @a2);
package Request;
sub aaa(\@\@)
{
my @array1 = @{shift()};
my @array2 = @{shift()};
}
1;
Notice how the prototype has to be pre-defined, like with C/C++. Very few people like or understand prototypes, so it might be better to use:
use warnings;
use strict;
#main.pl
my @a1 = qw (the quick brown fox);
my @a2 = qw (theres more than one way);
Request::aaa(\@a1, \@a2);
package Request;
sub aaa
{
my @array1 = @{shift()};
my @array2 = @{shift()};
}
1;
Here the caller has to know that a reference is being passed - that's the \ in front of the array (\@a1, \@a2)
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.