programming-examples/perl/Subroutine/Pass two array reference to a subroutine.pl
2019-11-15 12:59:38 +01:00

15 lines
341 B
Raku

@a = (1, 2, 3);
@b = (4, 5, 6);
sub addem
{
my ($reference1, $reference2) = @_;
for ($loop_index = 0; $loop_index <= $#$reference1; $loop_index++) {
$result[$loop_index] = @$reference1[$loop_index] + @$reference2[$loop_index];
}
return @result;
}
@array = addem (\@a, \@b);
print join (', ', @array);