9 Einträge, 1 Seite |
my @array = fuell_array();
1
2
3
4
5
6
7
8
my $ref = fill_array();
print @$ref, "\n";
sub fill_array {
push @_, qw/foo bar foobar/;
return \@_;
}
1
2
3
4
5
6
7
sub fuelle_array (\@) {
@{$_[0]} = qw(aaa bbb ccc ddd eee fff);
}
fuelle_array(my @array);
print "$_\n" for @array;
fuelle_array(\{my @array});
QuoteUnlike local variables in C or C++, Perl's lexical variables don't nec-
essarily get recycled just because their scope has exited. If some-
thing more permanent is still aware of the lexical, it will stick
around. So long as something else references a lexical, that lexical
won't be freed--which is as it should be. You wouldn't want memory
being free until you were done using it, or kept around once you were
done. Automatic garbage collection takes care of this for you.
This means that you can pass back or save away references to lexical
variables, whereas to return a pointer to a C auto is a grave error.
9 Einträge, 1 Seite |