1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl sub foo { my $a = "a"; my @b = ("b"); my @c = ("c"); return ($a, @b, @c); } my ($a, @b, @c) = foo; print "\@c "; print @c; print "\n"; print "\@b "; print @b; print "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#!/usr/bin/perl sub foo { my $a = "a"; my @b = ("b"); my @c = ("c"); return ($a, \@b, \@c); } my ($a, $b, $c) = foo; print "\@c "; print @$c; print "\n"; print "\@b "; print @$b; print "\n";
my @array = @{ $hash{'array'} };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/usr/bin/perl use diagnostics; use threads; use warnings; sub loop_threads { foreach my $thr (threads->list){ my ($a, $ref_b, $ref_c) = $thr->join(); print "\@c "; print @$ref_c; print "\n"; print "\@b "; print @$ref_b; print "\n"; } } sub foo { my ($a, $b) = @_; my @c = ("c"); return ($a, $b, \@c); } my $a = "a"; my @b = ("b"); threads->create({'context' => 'list'}, \&foo, ($a, \@b)); loop_threads();