From: "GMane Python" <[EMAIL PROTECTED]>
> 
> do
> {
>    my $MySocket=new IO::Socket::INET->new(Proto=>"udp",
>        PeerPort=>43278,
>        PeerAddr=>'10.151.24.174'
>          ) or die "Can't make UDP socket: $@";
>    $msg="PyHB";
> 
>    print "Sending Heartbeat.";
>    $MySocket->send($msg);
>    sleep (5);
> }
> while (1==1);
> 

Sorry, can't help with the problem, just commenting on the syntax ...

I believe most people would find your code easier to read if it was 
written like this:

while (1) {
   my $MySocket=new IO::Socket::INET->new(Proto=>"udp",
       PeerPort=>43278,
       PeerAddr=>'10.151.24.174'
         ) or die "Can't make UDP socket: $@";
   $msg="PyHB";

   print "Sending Heartbeat.";
   $MySocket->send($msg);
   sleep (5);
}


the 
        do
        {
        ...
        } while (something);
looks a bit scary to me. (Looks like the do...loop statement in 
Basic.) It's good if you do need to execute the loop contents before 
evaluating the condition for the first time, but in this case the 
condition is always true so there's no point.

I actually had to consult perldoc perlsyn, I did not remember "while" 
as a statement modifier works differently if the statement it 
modifies is do{} and if it's not so I thought the do{}while() would 
not work as expected.

Compare
        $x = 5;
        do {print "ahoj $x\n"} while ($x--);
and
        $x = 5;
        print "ahoj $x\n" while ($x--);

I find this a bit confusing.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to