Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > What is wrong in the following script

Reply
Thread Tools

What is wrong in the following script

 
 
Arun
Guest
Posts: n/a
 
      09-08-2008
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);
}
}
 
Reply With Quote
 
 
 
 
Josef Moellers
Guest
Posts: n/a
 
      09-08-2008
Arun wrote:

Perhaps you try to explain to us and to yourself, what this line is
supposed to do:

> DATA: while(<$handle=1>)


Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
 
Reply With Quote
 
 
 
 
Dr.Ruud
Guest
Posts: n/a
 
      09-08-2008
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;

--
Affijn, Ruud

"Gewoon is een tijger."
 
Reply With Quote
 
Eric Pozharski
Guest
Posts: n/a
 
      09-08-2008
Arun <(E-Mail Removed)> wrote:
> 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<use warnings;> instead.

> use IO::Socket;
> use diagnostics;


Use C<perldoc perldiag> instead.

> 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,


I'm not an B<IO::Socket::INET> expert, but I suppose you are going to
connect to empty port at empty address.

> 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.

--
Torvalds' goal for Linux is very simple: World Domination

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
What, if anything, is wrong with the following code fragment? Chris C++ 7 02-09-2005 09:27 PM
What is wrong with the following code ? Razvan C++ 3 06-22-2004 01:43 PM
RE: The Web server reported the following error when attempting to create or open the Web project located at the following URL: <URL> =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?= ASP .Net 0 06-07-2004 07:36 AM
What is wrong with the following code? willem oosthuizen VHDL 9 10-12-2003 03:07 PM



Advertisments