in reply to How $clientSocket->recv( $buffer, $length) pass the data back by a value-passed?
Consider:
my $value = 1; editValue ($value); print $value; sub editValue { $_[0]++; }
prints '2' because @_ contains aliases to the parameters passed into the sub. If you edit the contents of elements of @_ you are editing the contents of the parameters.
You can make it more explicit by taking a reference to an element:
sub editValue { my $value = \$_[0]; $$value++; }
|
|---|