peschkaj has asked for the wisdom of the Perl Monks concerning the following question:
Forgive me brothers, it has been a long time since I last sought your wisdom.
I am working on a socket server to monitor remote machines, and I thought that it would be nice to write a pair of functions, writeClient and writeLog. writeLog appears to be working just fine. However, writeClient throws
Can't use an undefined value at ./myPerlServ.pl line 150.
Here are some of the relevant pieces of code:
my $client; while ( $client = $server->accept() ) { ... writeClient("I'm trying to do something, really!"); } ... sub writeClient { ### Read args, take first arg and use it, dump the rest my ( $message, @junk ) = @_; my $clientMessage = "$message\r\n"; print $client $clientMessage; }
I'm curious, do I need to pass $client into writeClient and then dereference it? (References in Perl confuse me a great deal sometimes.) Or is there something else that I am completely missing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(z) Re: Undefined value as a symbol reference
by zigdon (Deacon) on Mar 11, 2003 at 13:45 UTC | |
|
Re: Undefined value as a symbol reference
by robartes (Priest) on Mar 11, 2003 at 13:47 UTC | |
|
Re: Undefined value as a symbol reference
by peschkaj (Pilgrim) on Mar 11, 2003 at 13:58 UTC |