Perl subroutine array and scalar variable parameters

后端 未结 3 1855
离开以前
离开以前 2021-02-14 06:53

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\         


        
3条回答
  •  你的背包
    2021-02-14 07:24

    You need to fetch them as references because you've already passed them as references (by using the \ operator):

    my($inVal, $inValTwo, $inArray, $inArrayTwo) = @_;
    

    and then use the references as arrays:

    @{$inArray}
    

提交回复
热议问题