Well my first thought on how you can manage this is using modules. If you are specifically tying one script to the other via passed variables, then the solution I suggest is using modules.
Try the following:
----- mainscript.pl
use SecondScript qw ( modify_array );
my @array = ('one', 'two', 3);
my @modified_array = @{modify_array(\@array)};
----- END
----- SecondScript.pm
package SecondScript;
use strict;
use warnings;
require Exporter;
use vars qw(@ISA @EXPORT_OK);
@ISA = qw(Exporter);
@EXPORT_OK = qw(modify_array);
sub modify_array {
my @array = @{(shift)};
# make your modifications here
return \@array;
}
----- END
The first script calls on the module called SecondScript as well as an Exported subroutine called modify_array. @array is declared with default values, then passed to the subroutine contained in SecondScript. Notice the backslash used, this is used to pass a reference of the array to the called subroutine.
The modify_array sub in the SecondScript module is called into action. The first thing it does is pull in the passed array and dereferences it into a local variable. There it will make whatever modifications you want it to and return a reference of that array (return \@array;).
And now.. back to the first script. It declares a new array called @modified array which will be populated wit the results returned by the modify_array subroutine in SecondScript.
BlackJudas