I have a Perl script embedded in a C program. I want to return an array of integers from the Perl script. However, the number n of integers to be returned, is an input to the program and cannot be hardcoded in the Perl script. Is there a way to do this? Here are a few examples:
Example 1 (n is known and equal to 2 in PERL subroutine):
@num = {1, 2, 3, 4};
($num[0], $num[1]); // works, returns the two values
Example 2 (n is not known):
@num = {1, 2, 3, 4};
(@num); // does not work
Example 3 (n is not known):
@num = {1, 2, 3, 4};
$string = "($num[0], $num[1], $num[2], $num[3])";
$string; // does not work