in reply to Why isn't the obvious dereferencing of the array working?
In addition, if you don't add these parens, you don't need to pre-declare your subroutine. So, your code could be:
But it could also be:use warnings; use strict; { my $temp2=testfunc(); my @arr=@$temp2; print @arr, $temp2," \n" ; #want @arr to print the array elements & $temp2 to print ref value } sub testfunc { my @temps= (1,2,3); return \@temps; }
use warnings; use strict; { my $temp2=testfunc(); my @arr=@$temp2; print @arr, $temp2," \n" ; #want @arr to print the array elements & $temp2 to print ref value } sub testfunc { my $temps= [1,2,3]; return $temps; }
|
|---|