Leser: 24
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
my %x=(a=>1,b=>2,c=>3); my @y=(1,2,3); sub func { my $ref_hash_x=shift(@_); my $ref_array_y=shift(@_); my %hash_x=%{$ref_hash_x}; my @array_y=@{$ref_array_y}; my @ret_a=(1,2,3); my %ret_b=('a',1,'b',2,'c',3); return(\@ret_a,\%ret_b); } my ($ref_array_ret_a,$ref_hash_ret_b)=func(\%x,\%y); my @array_ret_a=@$ref_array_ret_a; my %hash_ret_b=%$ref_hash_ret_b;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
sub set { my ($arg_ref) = @_; my @array = @{$arg_ref->{'foo'}}; my %hash = %{$arg_ref->{'bar'}}; my $string = ${$arg_ref->{'baz'}}; my @array1 = ["a" .. "z"]; my @array2 = ["A" .. "Z"]; return [\@array1, \@array2]; } # call my ($array1_ref, $array2_ref) = set({ foo => [0 .. 9], bar => { key => 'value', }, baz => \"test", });
Guest PeterWich möchte einer subroutine mehrere Listen und Hashes übergeben.