Sabacthani has asked for the wisdom of the Perl Monks concerning the following question:

Wrote my script, figured it all out, everything worked (finally). Then I tried to change it over to a cgi, and I got some strange (for me) errors in the error_log file. I can post the entire code if necessary, but I'm not sure that would help. First of all, the error:
Variable "$rsock" will not stay shared at... blah
This is my socket, declared thusly:
my $rsock = new IO::Socket::INET (PeerAddr => blah, PeerPort=> 12345, Proto => 'tcp', );
Shared by whom? And how can I make it stay shared? And what does this have to do with Apache, anyway (when I run it from command it's fine).
Secondly, I'm calling a sub like so:
sendData("0x4c",1,"LOGON USERNAME=NAME PASSWORD=pass\0");
And I get the error:
Too many arguments for Apache::ROOT::benjamin::ILX::cgi_2dbin::report_ +2ecgi::sendData

Again, I don't understand why the web server is even worrying about this, these are arguments I'm trying to pass to my sub function... Thank you in advance. I have been a little scared to post my questions here, but people where so fast, nice and helpful with my last series of questions that I fear no longer. Thanks!

Edit: chipmunk 2001-06-19

Replies are listed 'Best First'.
Re: Strange Apache errors with my CGI...
by chipmunk (Parson) on Jun 19, 2001 at 21:24 UTC
    A quick search for shared on the sites lists among the results the thread mod_perl: variable $end will not stay shared (nested subroutines problem). In short, you should declare that variable with use vars instead of my. Apache caches your script by wrapping the whole thing in a subroutine, which causes problems when you declare lexical variables in the main part of the script and then use them inside one of your subroutines.

    You haven't showed us how you defined the subroutine sendData, but apparently you gave it a prototype that specifies fewer arguments than you're calling it with. You may have done sub sendData () {} when you meant sub sendData {}.

Re: Strange Apache errors with my CGI...
by Anonymous Monk on Jun 19, 2001 at 23:51 UTC
    The name sendData rings a bell. Is there not a sub in mod_perl with the same name?