Just to expand on this point for the OP's benefit, consider:
use strict;
use Dumpvalue;
my $dumper = Dumpvalue->new();
my @a = (3, 1, 4, 1);
my @b = (5, 9);
my @c = (2, 6, 5);
sub ex1 {
map 10*$_, @_;
}
$dumper->dumpValue([ex1(@a)]);
print "\n";
# array refs
sub ex2 {
map scalar @$_, @_;
}
$dumper->dumpValue([ex2(\@a, \@b, \@c)]);
print "\n";
# implicit array refs through prototypes
sub ex3 (\@\@\@) {
map scalar @$_, @_;
}
$dumper->dumpValue([ex3(@a, @b, @c)]);
print "\n";
__END__
0 30
1 10
2 40
3 10
0 4
1 2
2 3
0 4
1 2
2 3
Note that the bodies of
ex2 and
ex3 are identical. IMO, however,
ex2 is superior, because it can take as arguments
any number of array refs, whereas
ex3 must take
exactly three arrays as arguments.
Follow-up question: is there any way to define a sub that takes as input one or more arrays?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.