How exactly can I pass both scalar variables and array variables to a subroutine in Perl?
my $currVal = 1;
my $currValTwo = 1;
my @currArray = ('one','two','three');
my @currArrayTwo =('one','two','three');
&mysub($currVal, $currValTwo,\@currArray, \@currArrayTwo);
sub mysub() {
# That doesn't work for the array as I only get the first element of the array
my($inVal, $inValTwo, @inArray, @inArrayTwo) = @_;
}
You need to fetch them as references because you’ve already passed them as references (by using the
\operator):and then use the references as arrays: