Reputation: 587
I am trying to pass a hash reference and array reference to subroutine but getting error like invalid class string:
sub test{
if($chk == 2)
{
return(\%hash,\@array);
}
}
my ($has, $arr)= test();
Now again i have to pass by reference to "$has, $arr"
to a another subroutine.
How to do this? i was passing them like \%$has, \@$arr
but it seems this is not the currect way to pass to a subroutine.
Upvotes: 0
Views: 98
Reputation: 11
my %Hash=('1'=>'one');
my @Arr=('1','2');
&fun(\%Hash,\@Arr);
sub fun(){
my $Hash_Ref=shift;
my $Arr_Ref=shift;
enter code here
&Fun2($Hash_Ref,$Arr_Ref);
} sub fun2(){
my $Hash_Ref=shift;
my $Arr_Ref=shift;
}
Upvotes: 0
Reputation: 91385
Just do:
anotherSub($has, $arr);
$has
and $arr
are already references.
Upvotes: 3