B
Bolin
How to modify a list in a subfunction? E.g. I want to pass a list as
an argument, and append it another list? Something like
sub append {
my $listRef = shift;
my @list = @$listref;
@list = (@list, @anotherlist);
return \@list;
}
Right now I have to return the pointer to make it work, can I find a
way to modify the imput argument without having to return the result,
or is that against Perl's coding style?
Another thing, I am also looking for an elegent way of initializing a
hash table with two lists, or a list an a value, e.g. sth like
@hash{@keyList} = @valueList or @hash{@keyList} = $value, which does
not work.
THanks
Bolin
an argument, and append it another list? Something like
sub append {
my $listRef = shift;
my @list = @$listref;
@list = (@list, @anotherlist);
return \@list;
}
Right now I have to return the pointer to make it work, can I find a
way to modify the imput argument without having to return the result,
or is that against Perl's coding style?
Another thing, I am also looking for an elegent way of initializing a
hash table with two lists, or a list an a value, e.g. sth like
@hash{@keyList} = @valueList or @hash{@keyList} = $value, which does
not work.
THanks
Bolin