in reply to Re: Scoping Issue
in thread Scoping Issue

Actually, that's not the problem at all. If you look at the OP, the first line of output after the "sdf" line shows that @command is in fact being set correctly. I was surprised too, but removing the parentheses and adding use warnings doesn't actually fix the problem.

The real problem, as best I can tell, has to do with connecting to this server using telnet(1) as your client. Somehow telnet is sending some special escapes which your program is choking on. Try adding the following line in "spawn" and you'll see what I mean: print "***$clientreq***\n";

Also, within your while loop you need to add this line, or else it will start spinning forever as soon as your first client disconnects:

last if !defined $clientreq;

Update: By the way, the --debug option in your code won't work the way you think it will. use warnings is lexically scoped, so in fact it will have no effect at all the way you've written it. To see what I mean, try this:

if (1) { use warnings; } print undef;

Note that you don't get an "uninitialized value" warning like you might expect to. One way you can work around this is with:

BEGIN { if ($ARGV[0] eq '--debug') { require warnings; warnings->import(); } }

Replies are listed 'Best First'.
Re: Re: Re: Scoping Issue
by castaway (Parson) on May 17, 2004 at 05:17 UTC
    There's no somehow about it, telnet is defined as having a bunch of internal commands which anyone using it should consider. It uses the 255 character to indicate that one or more following characters will be telnet options. (An actual 255 char is sent doubled.) See telnet protocol.

    (I've actually written a module to allow telnet options to be ignored/dealt with on any socket, but not gotten around to documenting/finishing it .. )

    C.

      some interesting points... I made the following changes but am still having the same problem. changed Socket to IO::Socket. removed the () in valid_req sub. removed the --debug option , and just made it use warnings; when i print "***$clientreq***\n" i get something like the following. >hello ***hello ...etc etc i don't see any extra chars... added the following line after my chomp. $clientreq =~ s/\n//g; no difference. any other ideas?