in reply to Re: Error "undefined value as a symbol reference "
in thread Error "undefined value as a symbol reference "

What should be corrected? (it's http-proxy script, I'd used ready code, I am not a very familiar in perl)
  • Comment on Re^2: Error "undefined value as a symbol reference "

Replies are listed 'Best First'.
Re^3: Error "undefined value as a symbol reference "
by jhourcle (Prior) on Apr 22, 2005 at 11:14 UTC

    When you open your socket, you can do something else if it didn't open. For instance, if you wanted the program to end immediately:

    my $server = IO::Socket::INET->new ( LocalPort => 8080, Type => SOCK_STREAM, Reuse => 1, Listen => 10) or die ("Can't open socket : $!");

    It's a good idea to check anything that has a potential to fail. (opening files, closing files that you've written to, opening database connections, etc.)

      After an implementing this correction, got a new error:
      Software error:
      Can't open socket: Address already in use at /home/www/myspace.superihost.com/cgi-bin/script.pl line 10.

        Then it looks like either another instance of your script or some other program is already using port 8080 - you can check this by telnetting to that part to see if you can connect or by using netstat -l, you can find the actual program that has the port open by doing sudo /usr/sbin/lsof -i:80 | grep LISTEN (if you have lsof that is.) If you are not committed to this port, try using another one.

        /J\