You can't return anything other than a short integer as a return code. The idea is that the return code is 0
if the program works, and non-zero otherwise.
You can return a string, then allow your shell script to parse that string as an array.
For example, if your @array = qw(one two three four five)
, simply print that as the only line on STDOUT. If you want to say anything else, print that to STDERR:
use strict;
use warnings;
use feature qw(say);
my @array = qw(one two three four five);
say STDERR "I'm about to print out the final array"; # Doesn't print to STDOUT...
say "(" . join ( " ", @array ) . ")"; # Prints to STDOUT
This program will print out:
(one two three four five)
Now in your shell script, you can do this:
declare -a shell_array=$(my_perl_prog.pl)