programming-examples/perl/Subroutine/Adding two arrays in a subroutine.pl
2019-11-15 12:59:38 +01:00

20 lines
246 B
Raku

@a = (1, 2, 3);
@b = (4, 5, 6);
@array = addem (\@a, \@b);
print @array;
sub addem
{
my ($ref1, $ref2) = @_;
while (@{$ref1}) {
unshift @result, pop(@{$ref1}) + pop(@{$ref2});
}
return @result;
}