In Perl 5 I can do this:

my @a = (1, 2);
my @b = (3);

foo(@a,@b);

sub foo { my $n = @_;  die "Wrong num args: $n" if ($n != 3);}

In Perl 6 I think this is correct (or nearly so):

sub foo(*@args) { die "Wrong num args: { @args.elems }" if @args.elems != 3;}

Questions for Perl 6:

foo is now defined as:

sub foo($a, $b, $c) { # do something with $a, $b, $c }

but I want to call it with a flattened array arg.

1.  How can I combine arrays @a and @b into one array?
2.  Can I flatten the arrays into elements inside the foo call?  If
not, what is the best way to pass the array elements to foo?

Thanks.

Best,

-Tom

Reply via email to