Hi,

%commands defined much earlier in the program and I want to see if $recv
matches a key in that array. That isn't the issue i'm having through. It
doesn't matter if the logic fails, regardless $recv suddenly has nothing in
it if I perform a chomp() on it.

Thanks,

Shane

On 11/10/2007, Tony Sceats <[EMAIL PROTECTED]> wrote:
>
> I would have thought the following makes more sense
>
>  if (defined($recv})) {
>      chomp($recv);
>      $client->send("Works! Received: $recv");
> }
>
> where's %commands coming from?
>
>
> On 10/11/07, Shane Anderson <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
> >
> > I'm attempting to learn IO::Socket and have hit a snag with this bit of
> > code:
> >
> > while (my ($client, $client_address) = $server->accept()) {
> >     my ($port, $packed_ip) = sockaddr_in($client_address);
> >     my $client_ip = inet_ntoa($packed_ip);
> >     my $stamp = &timestamp;
> >     print LOGFILE "$stamp - Client ($client_ip) connected.\n" if $DEBUG
> > ==
> > 1;
> >     $client->recv($recv, 128);
> >     chomp($recv);
> >
> >     if (exists($commands{$recv})) {
> >         $client->send("Works! Received: $recv");
> >     } else {
> >         $client->send("Doesn't work! We received this: $recv");
> >     }
> > }
> >
> > The code above doesn't print out anything for $recv, however if I remove
> > the
> > chomp($recv) it works fine. Anyone got any idea's why running a chomp on
> > this variable causes it to not be displayed at all? The variable does
> > contain a newline so I do need to have it removed.
> >
> > Thanks,
> >
> > Shane
> > --
> > SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> > Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
> >
>
>
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to