What is wrong in the following script

A

Arun

problem: excecutes only DATA string but nor IO1 and IO0.

script:

#!\usr\bin\perl -w

use IO::Socket;
use diagnostics;
use strict;
use POSIX qw(strftime);

my $remote_host = "";
my $remote_port = "";
my ($handle, $send_data,$send_i1,$send_i0,$count);

$count=0;
$handle= IO::Socket::INET->new( PeerAddr => $remote_host,
PeerPort => $remote_port,
Proto => "tcp",
Type => SOCK_STREAM
)
|| die "Couldn't connect to $remote_host:$remote_port: \n";

print STDERR "[Connected to $remote_host:$remote_port]\n";

DATA: while(<$handle=1>)
{
for($count=0;$count<180;$count++)
{
$send_data = self define string;
$handle-> send($send_data);
$count=0;
sleep(180);
}
}

IO1: while(<$handle=1>)
{
for($count=0;$count<240;$count++)
{
$send_i1 = self defined string
$handle-> send($send_i1);
$count=0;
sleep(240);
}
}

IO0: while(<$handle=1>)
{
for($count=0;$count<360;$count++)
{
$send_i0 = self defined string;
$handle-> send($send_i0);
$count=0;
sleep(360);
}
}
 
D

Dr.Ruud

Arun schreef:
#!\usr\bin\perl -w
[...]
use strict;

It won't solve your real problem, but it sure looks better:

#!/usr/bin/perl
use strict;
use warnings;
 
E

Eric Pozharski

Arun said:
problem: excecutes only DATA string but nor IO1 and IO0.

I would like to hear any answert to Josef Moellers's question too.

Meanwhile:
#!\usr\bin\perl -w

Use C said:
use IO::Socket;
use diagnostics;

Use C said:
use strict;
use POSIX qw(strftime);
my $remote_host = "";
my $remote_port = "";
my ($handle, $send_data,$send_i1,$send_i0,$count);
$count=0;
$handle= IO::Socket::INET->new( PeerAddr => $remote_host,
PeerPort => $remote_port,

Proto => "tcp",
Type => SOCK_STREAM
)
|| die "Couldn't connect to $remote_host:$remote_port: \n";
print STDERR "[Connected to $remote_host:$remote_port]\n";
DATA: while(<$handle=1>) *SKIP*
$send_data = self define string;

BTW, copy-paste your code. Don't retype.

*SKIP*
IO1: while(<$handle=1>) *SKIP*
IO0: while(<$handle=1>)
*SKIP*

I would like to know your intentions too. What you really achieved is:

23:38:09 69 [0:0]$ perl -mIO::Handle -wle '
$x = new IO::Handle; print <$x=1>'
IO::Handle=GLOB(0x814ed90)=1

I believe, that since filehandles aren't supposed to be assigned while
reading from them, Perl treats your construct as globbing (instead of
reading). Surprise? C<perldoc -f glob> has more.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top