sunshine_august has asked for the wisdom of the Perl Monks concerning the following question:
I notice that, $clientSocket->recv( $buffer, $length) can pass the data back to $buffer, even though the $buffer is value-passed, rather than ref-passed.
I write a test subroutine, if I want to pass the data back from a subroutine, I need to pass the variable by ref. like this:
if I pass it by value, it gets nothing back:my $buffer; foosub( \$bufffer ); print $buffer, "\n"; sub foosub { my $rs_buffer = shift; $$rs_buffer = "Hello, world"; }
my $buffer; foosub( $buffer); print $buffer, "\n"; sub foosub { my $buffer = shift; $buffer = "Hello, world"; }
so, why the recv() can pass the data back by a value-passed?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How $clientSocket->recv( $buffer, $length) pass the data back by a value-passed?
by GrandFather (Saint) on Sep 12, 2008 at 07:43 UTC | |
|
Re: How $clientSocket->recv( $buffer, $length) pass the data back by a value-passed?
by ikegami (Patriarch) on Sep 12, 2008 at 07:50 UTC | |
|
Re: How $clientSocket->recv( $buffer, $length) pass the data back by a value-passed?
by sunshine_august (Scribe) on Sep 12, 2008 at 09:27 UTC |