Hi all,
Can you please elaborate why"defined(<$new_sock>)"
does not assign data to $_ ?
My understanding was that although redundant
behavior in both cases should be identical.
Thank you,
Florentin.
----- Original Message -----
From: "Michael Fowler" <[EMAIL PROTECTED]>
To: "zentara" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, October 19, 2001 10:34 AM
Subject: Re: simple sockets
> On Fri, Oct 19, 2001 at 12:54:07PM -0400, zentara wrote:
> > ###########RECEIVE:################
> > #!/usr/bin/perl -w
> > use IO::Socket;
> > my $sock = new IO::Socket::INET (
> > LocalHost => 'localhost',
> > LocalPort => '7070',
> > Proto => 'tcp',
> > Listen => 1,
> > Reuse => 1,
> > );
> > die "could not create socket: $!\n" unless $sock;
> > my $new_sock = $sock->accept();
> > while(defined(<$new_sock>)) {
>
> This is your problem. while (<$new_sock>) assigns the data read from
> $new_sock to $_, but defined(<$new_sock>) does not. Change it to simply
> while (<$new_sock>) and everything should work fine. There is an implied
> defined test in that loop, so you don't need to test it yourself.
>
>
> > print $_;
> > }
>
> Actually, given the loop you have, it might be simpler and more readable
to
> use:
>
> print while <$new_sock>;
>
>
> > close($sock);
>
>
> Michael
> --
> Administrator www.shoebox.net
> Programmer, System Administrator www.gallanttech.com
> --
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]