[24061] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6258 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 15 11:05:36 2004

Date: Mon, 15 Mar 2004 08:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 15 Mar 2004     Volume: 10 Number: 6258

Today's topics:
        @$ in HTML::TableExtract???? (Greg)
    Re: @$ in HTML::TableExtract???? (Peter Scott)
        grepping for something, and then again for whatever cha <gned@telsmonopolytradotcom.remove.monopoly)>
    Re: grepping for something, and then again for whatever (Anno Siegel)
    Re: grepping for something, and then again for whatever <gned@telsmonopolytradotcom.remove.monopoly)>
        Hash as a function argument.. plz help! <karel@e-tunity.com>
    Re: Hash as a function argument.. plz help! $_@_.%_
        Having trouble passing arrays to functions (D. Alvarado)
    Re: Having trouble passing arrays to functions <jurgenex@hotmail.com>
    Re: How to remove lines containing "continuation" opera (werlax)
    Re: How to use select to wait for input (Anno Siegel)
        html2pdf -> HTML::HTMLDoc() ? (Bart Van der Donck)
    Re: IO::Pipe::close returns wrong value (Heinrich Mislik)
    Re: reading http parameters (Damian James)
    Re: Regex to match simple line of XML (ac)
    Re: Regex to match simple line of XML (ac)
    Re: Regex to match simple line of XML (ac)
    Re: Regex to match simple line of XML <tore@aursand.no>
    Re: Send variable from cgi to an html or php page <noreply@gunnar.cc>
        socket problem <sppNOSPAM@monaco377.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 14 Mar 2004 23:28:57 -0800
From: djbitchpimp@snowboard.com (Greg)
Subject: @$ in HTML::TableExtract????
Message-Id: <7e312ede.0403142328.65485547@posting.google.com>

I am trying to figure out how the following section of code works
(mostly from CPAN):

#! /usr/lib/perl

use LWP::Simple ;
use HTML::Parser ;
use HTML::TableExtract ;

$url = "http://wants.musicstack.com/" ;

$doc = get ($url) ;

for (my $i = 2; $i < 10; $i++)
     $te = new HTML::TableExtract( depth => 0, count => $i ) ;
     $te->parse($doc) ;

     foreach $ts ($te->table_states) {
           print "Table found at ", join(',', $ts->coords), ":\n";
           foreach $row ($ts->rows) {
                #print "   ", join(',', @$row), "\n";
                print @row ."\n" ;
           }
      }
}

I want to print out the individual elements of the row but it looks
like @$row is not a normal array.

Anyone know whats going on? Thanks in advance,

Greg


------------------------------

Date: Mon, 15 Mar 2004 14:46:30 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: @$ in HTML::TableExtract????
Message-Id: <alj5c.810494$ts4.2991@pd7tw3no>

In article <7e312ede.0403142328.65485547@posting.google.com>,
 djbitchpimp@snowboard.com (Greg) writes:
>I am trying to figure out how the following section of code works
>(mostly from CPAN):
[snip]
>           foreach $row ($ts->rows) {
>                #print "   ", join(',', @$row), "\n";
>                print @row ."\n" ;
>           }
>      }
>}
>
>I want to print out the individual elements of the row but it looks
>like @$row is not a normal array.
>
>Anyone know whats going on? 

$row is a reference to an array; @$row is that array.

perldoc perlref

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


------------------------------

Date: Mon, 15 Mar 2004 20:16:35 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: grepping for something, and then again for whatever character matched before
Message-Id: <40557419$0$3958$afc38c87@news.optusnet.com.au>

I am trying to cryptanalyse some Caesar ciphertext. If I have
a word such as 'iiwwjvn', I want to be able to grep my dictionary in
such a way that it can look for words that start with two digrams.

Is this possible?

cheers,

C3





------------------------------

Date: 15 Mar 2004 09:41:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: grepping for something, and then again for whatever character matched before
Message-Id: <c33tok$pil$1@mamenchi.zrz.TU-Berlin.DE>

C3 <gned@telsmonopolytradotcom.remove.monopoly)> wrote in comp.lang.perl.misc:
> I am trying to cryptanalyse some Caesar ciphertext. If I have
> a word such as 'iiwwjvn', I want to be able to grep my dictionary in
> such a way that it can look for words that start with two digrams.

A digram is any combination of two letters, so every word with four
or more letters starts with two digrams.

If you mean words beginning with two pairs of repeated letters, as in
your example, try /^(.)\1(.)\2/.  

If you mean any two given digrams, that's trivial.

Anno


------------------------------

Date: Mon, 15 Mar 2004 20:56:54 +1100
From: "C3" <gned@telsmonopolytradotcom.remove.monopoly)>
Subject: Re: grepping for something, and then again for whatever character matched before
Message-Id: <40557d8c$0$8354$afc38c87@news.optusnet.com.au>

Thanks. That worked. I am pleasantly surprised to see that command-line grep
likes the syntax, too.

cheers,

C3

> If you mean words beginning with two pairs of repeated letters, as in
> your example, try /^(.)\1(.)\2/.




------------------------------

Date: Mon, 15 Mar 2004 16:39:53 +0100
From: Karel Kubat <karel@e-tunity.com>
Subject: Hash as a function argument.. plz help!
Message-Id: <4055ce4a$0$161$e4fe514c@dreader5.news.xs4all.nl>

Hi all,
I have a problem with a snippet of code. I'm trying to pass a hash as an
argument to a function. Below is some test code:

--- snip snip
use strict;

my %map = {
    1 => 'one',
    2 => 'two',
    3 => 'three',
};

sub fun {
    my $what = shift;
    my %hash = @_;

    print ("$what: ");
    foreach my $k (keys (%hash)) {
        print (" [$k]=[$hash{$k}]");
    }
    print ("\n");
}

# Why won't this work..
fun ("whatever", %map);

# But this will ?!
fun ("again",
     'a' => 'first char', 'b' => 'second');
--- snip snip

What am I doing wrong (obviously near the comment mark "why won't this
work")? Any and all help will be appreciated!

Thanks in advance,
-- 
Karel Kubat <karel@e-tunity.com, karel@qbat.org>
Phone: mobile (+31) 6 2956 4861, office (+31) (0)38 46 06 125
PGP fingerprint: D76E 86EC B457 627A 0A87  0B8D DB71 6BCD 1CF2 6CD5

  From the duffynitions collection:
  Mistress: Something between a mister and a mattress.



------------------------------

Date: Mon, 15 Mar 2004 15:46:56 GMT
From: $_@_.%_
Subject: Re: Hash as a function argument.. plz help!
Message-Id: <Qdk5c.6793$Q2.64@nwrdny03.gnilink.net>


Karel Kubat <karel@e-tunity.com> wrote in message-id:
<4055ce4a$0$161$e4fe514c@dreader5.news.xs4all.nl>
>
>Hi all,
>I have a problem with a snippet of code. I'm trying to pass a hash as an
>argument to a function. Below is some test code:
>
>--- snip snip
>use strict;
>
>my %map = {
>    1 => 'one',
>    2 => 'two',
>    3 => 'three',
>};
>
>sub fun {
>    my $what = shift;
>    my %hash = @_;
>
>    print ("$what: ");
>    foreach my $k (keys (%hash)) {
>        print (" [$k]=[$hash{$k}]");
>    }
>    print ("\n");
>}
>
># Why won't this work..
>fun ("whatever", %map);
>
># But this will ?!
>fun ("again",
>     'a' => 'first char', 'b' => 'second');
>--- snip snip
>
>What am I doing wrong (obviously near the comment mark "why won't this
>work")? Any and all help will be appreciated!
>
>Thanks in advance,
>--
>Karel Kubat <karel@e-tunity.com, karel@qbat.org>
>Phone: mobile (+31) 6 2956 4861, office (+31) (0)38 46 06 125
>PGP fingerprint: D76E 86EC B457 627A 0A87  0B8D DB71 6BCD 1CF2 6CD5
>
>  From the duffynitions collection:
>  Mistress: Something between a mister and a mattress.

I think you have to pass a referance to the subroutine.

$href = \%hash;
somesub($href);




------------------------------

Date: 15 Mar 2004 07:14:23 -0800
From: laredotornado@zipmail.com (D. Alvarado)
Subject: Having trouble passing arrays to functions
Message-Id: <9fe1f2ad.0403150714.3eea298f@posting.google.com>

Hi there,
   I'm having trouble passing arrays to a function.  Here is the
function definnition:

sub importData
{
     my (@p_command_line_args, $mdr_tech_file, $p_mdr_tech_table,
$primary_col_name, @p_fieldDescriptors, $p_numOfCharsPerLine,
$p_linesProcessed) = @_;
     print @p_command_line_args . "\n";
     ...
}

the invocation call is:

print @ARGV . "\n";
importData(
        @ARGV,
        $mdr_tech_table,
        $primary_key_col,
        @fieldDescriptors,
        $numOfCharsPerLine,
        $linesProcessed
);


I pass 6 arguments to my perl script, but my output is 

6
85

My question is, how is "@p_command_line_args" suddenly 85 instead 6? 
What is a better approach/syntax to what I'm doing here?

Thanks for your help - Dave


------------------------------

Date: Mon, 15 Mar 2004 15:39:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Having trouble passing arrays to functions
Message-Id: <D6k5c.107348$6K.42031@nwrddc02.gnilink.net>

D. Alvarado wrote:
> Hi there,
>    I'm having trouble passing arrays to a function.  Here is the
> function definnition:
>
> sub importData
> {
>      my (@p_command_line_args, $mdr_tech_file, $p_mdr_tech_table,
> $primary_col_name, @p_fieldDescriptors, $p_numOfCharsPerLine,
> $p_linesProcessed) = @_;

Here @p_command_line_args gobbles up all the parameter which are passed to
importData, so there is nothing left for the other variables.

> My question is, how is "@p_command_line_args" suddenly 85 instead 6?

Please see the second paragraph in perldoc perlsub about parameter passing.

> What is a better approach/syntax to what I'm doing here?

Use references.

jue




------------------------------

Date: 15 Mar 2004 06:43:40 -0800
From: werlax@hotmail.com (werlax)
Subject: Re: How to remove lines containing "continuation" operator
Message-Id: <744cd116.0403150643.5e3c96e3@posting.google.com>

"Suresh Govindachar" <sgovindachar@yahoo.com> wrote in message news:<7IP4c.8492$_3.107020@typhoon.sonic.net>...
> my $onelinertemplate = '^\s*#pragma.*[^\\\\\\r\\n]+$';
> my $starttemplate    = '^\s*#pragma.*\\\\$';
> my $endtemplate      = '[\\\\]$';
> 
> my @non_pragma_c;
> 
> push @non_pragma_c,
>      grep !(/$starttemplate/ .. !/$endtemplate/),
>      grep !/$onelinertemplate/, (<DATA>);
> 
> print @non_pragma_c;
> 
I've added the line 
local ($^I, @ARGV) = ('.bak', glob("*.cpp"));
prior to the variable definition and changed the <DATA> to just use
<>.  This is my first time trying to use the INPLACE EDIT feature and
it doesn't seem to be working.  A .bak copy of the original file is
created, but the print statement just prints to STDOUT.  From reading
the manpage I thought it was supposed to automatically use the
original filename as the default for print commands?  What am I
missing?
Thanks for all the help!
Mark


------------------------------

Date: 15 Mar 2004 10:18:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to use select to wait for input
Message-Id: <c33vt3$pil$2@mamenchi.zrz.TU-Berlin.DE>

Joe <jbstick@aol.com> wrote in comp.lang.perl.misc:
> I am trying to wait until some commands are appended to a text file.
> I tried using select as in the script below, but find that select always
> returns immediately, even if the file is empty or at end of file.
> What am I missing??
> 
> sysopen(CMND,$command_file,O_RDONLY);
> $rin = '';
> vec($rin,fileno(CMND),1) = 1;
> 
> # while (1) {
> for ($i = 0; $i < 3; $i++) {
>   $cmnds = '';
>   $nfound = select($rout=$rin, undef, $eout=$rin, 10);
>   if ($nfound) {
>     $count = sysread CMND,$cmnds,2048;
>     if ($count) {
>       MsgLog("select returns: $nfound, sysread returns: $count,
> Received:$cmnds");
>     }
>    else { MsgLog("select returned, but no input"); }
>   }
>   else { MsgLog('no commands'); }
> }

Select is used for streams like sockets, terminals and the like.  For
a disk file, read to the end, sleep some time, reset EOF with
seek( $fh, 0, 1) and repeat.  See recipe 8.5 in the _Perl Cookbook_.

Anno


------------------------------

Date: 15 Mar 2004 02:08:26 -0800
From: bart@nijlen.com (Bart Van der Donck)
Subject: html2pdf -> HTML::HTMLDoc() ?
Message-Id: <b5884818.0403150208.2efcaf5c@posting.google.com>

Hello,

I am looking for a way to dynamically generate PDF file in browser,
based on html input. It should run as a CGI (preferred in perl). The
program should be feeded with html code and convert it to a pdf file.

The CPAN list that could help, is at:
http://cpan.uwinnipeg.ca/search?query=pdf&mode=dist
I tested with PDF::Create. That works, but it only accepts plaintext
as input. This is too light.

Then I tried "DocSet" module. It seems a very large and complex
module. I am not sure if it can do what I want.

The best option seems to work with HTML::HTMLDoc(). It is a handy
module that talks to /usr/bin/htmldoc, a unix program that is
available on my system and on most unix systems, I suppose. It is a
program that can convert html 3.2 into PDF (info htmldoc:
http://www.easysw.com/htmldoc/).

So I installed HTML::HTMLDoc(), ran all tests and it should be OK to
make my PDF files with. However I cannot get any content in my pdf
file (it remains blanco). My small test program returns no errors,
only my PDF remains blanco as if I didn't feed it with input.

The docs of HTML::HTMLDoc() can be found at:
http://cpan.uwinnipeg.ca/dist/HTML-HTMLDoc

Here is the standard test-file of the author that uses
HTML::HTML::Doc();
http://cpan.uwinnipeg.ca/htdocs/HTML-HTMLDoc/HTML/HTMLDoc.html#synopsis
I use this as test program, but I changed
```` my $htmldoc = new HTML::HTMLDoc(); ´´´´
into
````my $htmldoc = new HTML::HTMLDoc('mode'=>'file', 'tmpdir'=>'/tmp');
 ´´´´
because of an issue with mod_perl
See here why I did that: last parapgraph at:
http://cpan.uwinnipeg.ca/htdocs/HTML-HTMLDoc/HTML/HTMLDoc.html#description

I did pretty intensive search why the program won't work. My best bet
is that /usr/bin/htmldoc is somehow not compiled with the necessary
options. (like only available as GUI on the machine itself) (?)

So my questions are:
- am I looking for eskimos in the desert?
- is there a "standard" way to create PDF from HTML input on unix
systems?
- are there ready-to-go scripts (perl, php,....) for this job
- are you a PDF or HTMLDOC sultan ?

regards
Bart


------------------------------

Date: 15 Mar 2004 12:57:38 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: Re: IO::Pipe::close returns wrong value
Message-Id: <4055a83d$0$29350$3b214f66@usenet.univie.ac.at>

In article <HuGt0F.Mx7@news.boeing.com>, ced@bcstec.ca.boeing.com says...

>And from perldoc -f close:
>
>  Closing a pipe also waits for the process executing on the pipe 
>  to complete, in case you want to look at the output of the pipe 
>  afterwards, and implicitly puts the exit status value of that  
>  command into "$?".

Just before this it says:

 If the file handle came from a piped open "close" will addi-
 tionally return false if one of the other system calls involved
 fails or if the program exits with non-zero status.

But Pipe::close returns true, even if the program returns non-zero.

>To verify:
>
>   close $pipe or warn "command @prog filed";
>   print "\$? from pipe close = $?\n";        #----- prints 512
>   ...
>   $pipe->close or warn "command @prog filed";
>   print "\$? from pipe close = $?\n";        #---- prints 512

True, but only the first warning is printed, and I think, this 
is not as documented.

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



------------------------------

Date: 15 Mar 2004 07:03:56 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: reading http parameters
Message-Id: <slrnc5alas.ijb.damian@puma.qimr.edu.au>

On Mon, 15 Mar 2004 12:04:53 +0800, Andrew Chan said:
>I'm new to Perl.
>
>can anybody tell me how i can strip data from a apache logfile so that i can
>see the words being searched?
>
>"GET /cgi-bin/htsearch?words=test1&template..."
>In this case, I would like to search for "test1"
>
>"GET /cgi-bin/htsearch?words=test1+test2&template..."
>In this case, I would like to search for "test1 test2"
[warning: untested]

my %terms;
while (my $line = <>) {
	next unless $line =~ m{^GET /cgi-bin/htsearch\?words=([\w+]+)&};
	my @matches = sort(split /\+/, $1);
	$terms{ $_ }++ for @matches;
	$terms{ "@matches" }++;
}
print "$_=$hits{$_}\n" for sort keys %terms;

>Then I would want to generate to a file with the following results:
>
>test1=10
>test1 test2=11

You don't say whether the second value is total counts of each term,
or for the combination. I assumed the latter.

--damian


------------------------------

Date: 15 Mar 2004 06:52:33 -0800
From: aclarke@austin.rr.com (ac)
Subject: Re: Regex to match simple line of XML
Message-Id: <ec432b9c.0403150652.56c63629@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<40525704.77006825@news.erols.com>...
> aclarke@austin.rr.com (ac) wrote:
> 
> : Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.03.12.18.17.26.789699@aursand.no>...
> : > On Fri, 12 Mar 2004 09:47:36 -0800, ac wrote:
> : > > I am trying to get a regex to match a simple line of XML.
> : > 
> : > Why?  What's wrong with the many XML modules?
> : 
> : Speed is critical here.
> :
> : You'll notice that I'm benchmarking against using
> : split, which is what my current implementation uses. 
> 
> Have you benchmarked against a real XML parser yet, or are you
> prematurely optimizing?

I'm balancing several constraints at one time. ;-) I was interested in
staying with pure Perl, so many parsers are not an option. I also
figured that a straight pattern match against a simplified XML format
would be faster than any pure Perl against full fledged XML.

> 
> : I'm trying to figure
> : out the best case if I move my data representation over to XML (from CSV).
> 
> What was wrong with CSV that XML will cure?

I have a table structure with a complex header that matches very well
to XML. The actual table rows are less of a match. I guess one way to
handle this would be to have XML data at the top of the file, then CSV
oriented data following that. But the problem is then its not a valid
XML file anymore.
 
> : To stay with speed, I'm willing even to insist that for these XML files,
> : that the entire element be physically one a single line. So this is really
> : a subset of legal XML files and isn't really a problem because my application
> : controls both the reading and writing of these.
> 
> If you have one Perl process talking to another through a file, why
> bring XML into the picture?  The Storable and Data::Dumper modules do
> a jim dandy job of saving data in a format that can be quickly loaded.

The consumers of the file are not always Perl. Also the files can get
quite large (network capture data), going over several hundreds of MB.


------------------------------

Date: 15 Mar 2004 06:54:02 -0800
From: aclarke@austin.rr.com (ac)
Subject: Re: Regex to match simple line of XML
Message-Id: <ec432b9c.0403150654.39699e8e@posting.google.com>

Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.03.13.10.00.42.842492@aursand.no>...
> On Fri, 12 Mar 2004 15:12:47 -0800, ac wrote:
> >>> I am trying to get a regex to match a simple line of XML.
>  
> >> Why?  What's wrong with the many XML modules?
>  
> > Speed is critical here.
> 
> And your point is?  The XML modules I've tried have been "fast enough".
> What are you comparing against?

I'm comparing against an implementation in Perl that I have now that
is CSV based. Its not terribly speedy and I'd really like a move to
XML (or a restricted XML) to not slow things down even further.


------------------------------

Date: 15 Mar 2004 06:55:20 -0800
From: aclarke@austin.rr.com (ac)
Subject: Re: Regex to match simple line of XML
Message-Id: <ec432b9c.0403150655.2409f40@posting.google.com>

wherrera@lynxview.com (Bill) wrote in message news:<239ce42f.0403131006.2964a7df@posting.google.com>...
> aclarke@austin.rr.com (ac) wrote in message news:<ec432b9c.0403121512.3484b991@posting.google.com>...
> > Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.03.12.18.17.26.789699@aursand.no>...
> > > On Fri, 12 Mar 2004 09:47:36 -0800, ac wrote:
> > > > I am trying to get a regex to match a simple line of XML.
> > > 
>  
> > So this is really
> > a subset of legal XML files and isn't really a problem because my application
> > controls both the reading and writing of these.
> 
> If so, and you only have one or several matches to do, why not write a
> unique comment tag to anchor your match? That would be fastest.

I assume that you mean if I am writing table rows, then use "<ROW..."
as the beginning of the regex match. That sounds reasonable. I'll
benchmark it.


------------------------------

Date: Mon, 15 Mar 2004 16:21:12 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Regex to match simple line of XML
Message-Id: <pan.2004.03.15.15.21.12.32407@aursand.no>

On Mon, 15 Mar 2004 06:54:02 -0800, ac wrote:
>>> Speed is critical here.

>> And your point is?  The XML modules I've tried have been "fast enough".
>> What are you comparing against?

> I'm comparing against an implementation in Perl that I have now that is
> CSV based.

Show us the current implementation, and we will help you speed it up (if
possible).


-- 
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." -- J. Robert Oppenheimer,
 upon witnessing the explosion of the first atomic bomb.


------------------------------

Date: Mon, 15 Mar 2004 10:18:53 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Send variable from cgi to an html or php page
Message-Id: <c33slc$23ih3f$1@ID-184292.news.uni-berlin.de>

Derek wrote:
> I have an html form which send details entered in form to a perl
> script (cgi)
> 
> How can i send variables from a cgi script back to an html or php
> page.

*Back* to? You don't send anything "back" to an existing page, but you
let the CGI script print a new one.

Having a CGI script ending up in a PHP page is a little more
complicated. If you really want a PHP page, you may want to have the
form send the data to a PHP script instead.

Note that this is not the right newsgroup for discussing these things.
If you would have a *specific* problem after having given it a try,
comp.infosystems.www.authoring.cgi is a more appropriate group.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



------------------------------

Date: Mon, 15 Mar 2004 16:24:50 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <sppNOSPAM@monaco377.com>
Subject: socket problem
Message-Id: <4055cac4$0$295$626a14ce@news.free.fr>

Hi all,

I've a little problem on socket.
My program need to connect to a TCP server, that fork every time a new
connection came, and send him datas every 3 sec.
If the server cut the remote socket, this program need to detect it print
"Unable to write" or "timeout" and finally "Hello World".

My problem: if the server cut the connection (for example doing a kill on
the server pid), my program end with:
"send: Cannot determine peer address at single.pl line 22"
and stop.

I've clean my source code to a very simple program.
Here is the source code:
#========================================================================
#!/usr/bin/perl -w
use strict;
use IO::Select;
use IO::Socket;
my $socket='';
unless ($socket = IO::Socket::INET->new(PeerAddr=> 'aaa.bbb.ccc.ddd',
                                PeerPort=> '21110',
                                Proto=> "tcp",
                                Timeout=>10,
                                Type=> SOCK_STREAM))
    {
        print ("Unable to connect \n");
        exit 1;
    }
my $s=IO::Select->new();
$s->add($socket);
while(1){
    if ($s->can_write(10)){      # ===>>> OK even if the socket is closed
        unless ($socket->send('@025123459876556789L@@')){ #====>CRASH-->bash
            print "Unable to write\n";
            last;
        }
        print "sent\n";
    }
    else {
        print "timeout\n";
        last;
    }
    sleep 3;
}
$s->remove($socket);
$socket->shutdown(0);
print "Hello World\n";
exit;
#==========================================================================

Here is the STDOUT of this program when I kill the server process:

#> perl single.pl
sent
sent
sent
send: cannot determine the peer address at single.pl line 22
#>

my OS: RedHat 8.0 kernel 2.4.18-14
Perl v5.8.0

Thanks in advance for any kind of help.

Sébastien Cottalorda

-- 
[ retirer NOSPAM pour répondre directement
 remove NOSPAM to reply directly ]


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6258
***************************************


home help back first fref pref prev next nref lref last post