[19974] in Perl-Users-Digest
Perl-Users Digest, Issue: 2169 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 21 09:06:03 2001
Date: Wed, 21 Nov 2001 06:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006351512-v10-i2169@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 21 Nov 2001 Volume: 10 Number: 2169
Today's topics:
Re: Anyone Read "Programming the Perl DBI" lately? <djberg96@hotmail.com>
Re: buggy regexp again.... <real@earthling.net>
Re: Can I avoid 2 passes? <pne-news-20011121@newton.digitalspace.net>
Re: Do Not Redirect CGI Questions To CIWAC <mgjv@tradingpost.com.au>
Re: File locking question (Anno Siegel)
File upload in Internet Explorer using Perl (Nitin Ghai)
Re: fork() help needed (Jere Eerola)
Re: Generating graphs using Perl for Windows <andrew_harton@agilent.com>
Re: has anyone tried activestate perl under solaris? <pne-news-20011121@newton.digitalspace.net>
Re: has anyone tried activestate perl under solaris? <djberg96@hotmail.com>
HELP: buggy regexp again.... (Bruno Boettcher)
Re: HELP: buggy regexp again.... <Tassilo.Parseval@post.rwth-aachen.de>
Re: HELP: buggy regexp again.... <bernard.el-hagin@lido-tech.net>
Re: HELP: buggy regexp again.... (Bruno Boettcher)
How to split variable length row <nospam@newsranger.com>
Re: How to split variable length row <bernard.el-hagin@lido-tech.net>
Re: How to split variable length row (Anno Siegel)
installing DBD::mysql on linux <asukardi@hns.co.id>
IO::Select and IO::Socket question: multiple connection <zoltan.kandi@tellabs.com>
IO::Select and IO::Socket question: multiple connection <zoltan.kandi@tellabs.com>
Re: Just wondering ... why is there no "since" informat <mgjv@tradingpost.com.au>
Re: Just wondering ... why is there no "since" informat <edgue@web.de>
LWP::UserAgent Post & Session problem (derek chen)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Nov 2001 05:59:16 GMT
From: "Daniel Berger" <djberg96@hotmail.com>
Subject: Re: Anyone Read "Programming the Perl DBI" lately?
Message-Id: <UoHK7.26$fN3.38286@typhoon.mn.mediaone.net>
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3BF9AFB3.CAB09DD5@vpservices.com...
> Alicia Hirsch wrote:
> >
> > kindly show me how DBI support multiple tables in a
> > single SQL statement
> > ...
> > I created 3 flat-file databases
>
> You can't currently do joins (which is what that is called) with
> flat-files. In about two weeks you will be able to when I release the
> new SQL::Statement module that supports joins with flat files. If you
> can't wait until then, email me and I'll send you an advance copy.
>
> --
> Jeff
That's interesting. Thanks Jeff. Hopefully Tim and O'Reilly are
considering a 2nd edition for the book sometime next year with the changes
he's made since 1.14 and some of the modules that have come out since.
Regards,
Dan
------------------------------
Date: Wed, 21 Nov 2001 11:03:59 +0100
From: "Real" <real@earthling.net>
Subject: Re: buggy regexp again....
Message-Id: <9tfu6g$632$1@news.surfnet.nl>
"Bruno Boettcher" <bboett@bboett.dyndns.org> wrote in message
news:9tform$9s1$1@wanadoo.fr...
> again i have some problem with my regexps....
>
> my incoming lines are diversely formatted but roughly of this schema:
>
> some directories:
> Fruit Basket
> infinite ryvius
> Kemzenak
>
> and some files
>
> 02-still_rain-asx.mp3 (6.35 MB)
> anything_not_in_folders_is_incomplete (0 B)
> sweet_november.avi (60.00 kB)
> infinite_ryvius_-_06.avi 158371840b
>
> etc....
> and as you may have guessed i want to detect the lines specifying a file
> (having a size info at the end) and then remove that last part...
>
> so i set up the following regexp:
> if($line =~ /\d+( ?b| ?k| ?kb| ?mb)\s*$/i ||
> $line =~ /\(\s*\d+\s*b|k|kb|mb\)$/i)
>
>
> which works fine in most cases, but somehow lines as
> Fruit Basket
> Kemzenak
>
> slip through and are tagged as files, making me completely astonished,
> since IMHO they are far from beeing able to be matched by the
> regexp...
This regexp works on the sample data :
if ( $line =~ /\(*\d+\.*\d*\s*(b|k|kb|mb)\)*$/i ) { print $line; }
> Since i am at it, performance speaking, what's better, making hughe
> regexps separated by '|' or make an array with the regexps and loop over
> that one?
My guess is that if you do things in 1 go, it's faster by definition. But
that's arguable of cause.
Bye,
Real
------------------------------
Date: Wed, 21 Nov 2001 12:21:42 +0100
From: Philip Newton <pne-news-20011121@newton.digitalspace.net>
Subject: Re: Can I avoid 2 passes?
Message-Id: <jd0nvtosbr42si1d0upjs3udkfuplke11n@4ax.com>
On Wed, 21 Nov 2001 02:30:26 GMT, "E.Chang" <echang@netstorm.net> wrote:
> Uri Guttman <uri@stemsystems.com> wrote in
> news:x7bshxdx1t.fsf@home.sysarch.com:
>
> > %users = map split (/:/, $_, 2), <PW> ;
>
> Sweet. I was hoping someone would point out a compact improvement like
> that.
Of course, that assumes the size of your /etc/passwd is not an
appreciable fraction of the memory you have :)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 21 Nov 2001 23:04:10 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Do Not Redirect CGI Questions To CIWAC
Message-Id: <slrn9vn61q.mfo.mgjv@martien.heliotrope.home>
On Tue, 20 Nov 2001 13:41:35 -0800,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>
> I will state again what I have recently stated.
> Do not redirect people with cgi questions to
> the comp.infosystems.www.authoring.cgi group.
[Do not pay any attention to what Godzilla says. It is a troll, and has
no decent working knowledge of Perl or programming in general. Search
groups.google.com to see a history of its posts and replies to these
posts.]
Do not get drawn into discussions with the troll.
CGI questions are offtopic here. The best place to redirect them is
comp.infosystems.www.authoring.cgi.
Martien
--
|
Martien Verbruggen | Little girls, like butterflies, need no
| excuse - Lazarus Long
|
------------------------------
Date: 21 Nov 2001 11:16:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File locking question
Message-Id: <9tg2f3$r0t$1@mamenchi.zrz.TU-Berlin.DE>
According to Laocoon <Laocoon@eudoramail.com>:
> Is this a Perl question? If it is..
Is what a Perl question? Please quote enough original material so your
readers know what you're talking about. I'm reproducing it here:
> > does anyone know how to lock a file move?
> >
> > file A -> file B
> >
> > File A is read and then removed, file B is written.
> > A simple 'mv' is not sufficient, is it?
> open(IN,"input") or die "Input : $!";
> open(OUT,">output") or die "Output : $!";
> $in = join "" , <IN>;
Why are you reading the whole file at once? There is no reason.
> close(IN);
> `del input`;
This is wrong in multiple ways. For one, don't use backticks to call
an external program when you don't care for its output. If you had
switched on warnings, Perl would have told you so. Second, *if* you
use an external program, check for its success. Third, don't use an
external program if a Perl builtin exists for the same purpose. "del"
doesn't exist in many environments. See perldoc -f unlink. So the line
should have been
unlink "input" or die "Can't unlink 'input': $!";
> print OUT $in;
> close(OUT);
Your program only does (badly) what the OP said he's been doing anyway.
The question was how to rename the newly written file to the name of
the original input file. You don't even mention this.
To the OP:
In a typical Unix environment, mv (and Perl's near-equivalent rename())
is an atomic operation, so a simple rename should suffice. There may
be snags if the files are on an NFS-mounted file system, but even then
people usually just rename their files.
Anno
------------------------------
Date: 20 Nov 2001 22:56:36 -0800
From: ghainitin@yahoo.com (Nitin Ghai)
Subject: File upload in Internet Explorer using Perl
Message-Id: <e9ed9a28.0111202256.1b37ea43@posting.google.com>
Hi,
In our applcation we are using the file upload utility of Perl. The
files are uploaded to a UNIX server and the application is located on
another server.
We are having problems in calculating the size of the file in IE, the
same code is working in NN4.7. But when we try to calculate the file
size using -s($filename), it is giving "" as size for all the files in
IE(as it is not able to access the file; 'fileexists' option returns
"" in IE, while in NN the same command returns 1 , thus the
conclusion!).
Can anyone please throw some light on this
Thanks in Advance
Nitin
------------------------------
Date: Wed, 21 Nov 2001 06:33:25 GMT
From: jee@gandalf.moon.org (Jere Eerola)
Subject: Re: fork() help needed
Message-Id: <slrn9vmili.qt.jee@rltrekary.radiolinja.fi>
On 20 Nov 2001 15:12:26 -0600, Logan Shaw <logan@cs.utexas.edu> wrote:
>In article <slrn9vko6f.qt.jee@rltrekary.radiolinja.fi>, Jere Eerola <at> wrote:
>>What I would really
>>like to do is write perl program which checks if there is
>>already five processes running and if not starts another one.
>>
>>I already wrote program that starts 5 processes but can't get any
>>further. Any advise or point to documentation or examples is very
>>much appreciated.
>
>The easiest way to do approach this problem is to start 5 processes and
>then use wait() to ask the system to inform you when one of them
>exits. Here's an example.
>
Thank you! This was exactly the information I needed. Now I can start
adding new features to my little script.
--
Jere Eerola
------------------------------
Date: Wed, 21 Nov 2001 10:08:16 -0000
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: Generating graphs using Perl for Windows
Message-Id: <1006337303.884799@cswreg.cos.agilent.com>
"Just in" <justin.devanandan.allegakoen@intel.com> wrote in message
news:9tet10$cpm@news.or.intel.com...
> > One problem with that is that it requires the GD libraries, which in
turn
> > require png libraries, zlib libraries, and jpeg libraries (and so on, it
> > seems). I was hoping to steer clear of all of that, since
> > 1) I have no real experience of installing and linking libraries
> > and
> > 2) I was hoping for something that could be easily sent out to others
> > without requiring them to do anything more than put one or two files in
> the
> > appropriate places - the simpler the better.
>
> Since we're talking Windoze here, a common assumption we could make
> is that all the 'others' have Excel.
Unfortunately, that assumption is not correct - the PCs in question are the
ones in the inspection machines that we sell, and we don't supply MS Office
with them.
I have been directed to this;
http://developer.netscape.com/docs/technote/javascript/graph/
- it seems to be a pretty neat solution. I can just include the javascript
code when generating the HTML output. It's limited to bar graphs, but that
was all I was looking for anyway.
Andrew
------------------------------
Date: Wed, 21 Nov 2001 12:21:47 +0100
From: Philip Newton <pne-news-20011121@newton.digitalspace.net>
Subject: Re: has anyone tried activestate perl under solaris?
Message-Id: <hg1nvt0dm8e4efpfms4t4mt7rokslbpkar@4ax.com>
On Tue, 20 Nov 2001 20:33:31 -0500, aaa <nobody@nowhere.com> wrote:
> Hi just wondering about people's opinion of activestate's perl
> distribution for solaris?
> If you've tried it, let me know what you like and dont like about
> it.....
I've used it on a machine where it was installed. And it was sometimes
handy that the base distribution contained a fair number of bundled
modules (eg LWP), and that (some) modules could be installed with 'ppm'
(which is handy when you don't have a C compiler around, which was the
case for a while on that particular Solaris box).
But other than that, there wasn't anything much special about it that I
could see. And I don't consider 'download; perl Makefile.PL; make; make
test; make install' or even 'perl -MCPAN -e "install Ex::am::ple"' to be
that difficult (as long as you have a C compiler for those modules that
need it).
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 21 Nov 2001 11:43:24 GMT
From: "Daniel Berger" <djberg96@hotmail.com>
Subject: Re: has anyone tried activestate perl under solaris?
Message-Id: <wrMK7.126$fN3.50820@typhoon.mn.mediaone.net>
"aaa" <nobody@nowhere.com> wrote in message
news:3BFB046B.889982DB@nowhere.com...
> Hi just wondering about people's opinion of activestate's perl
> distribution for solaris?
> If you've tried it, let me know what you like and dont like about
> it.....
I've tried it. Works fine. If you want the tools that come along with
ActiveState's distro then use ActiveState. Otherwise, build your own Perl.
Oh, and use gcc as your compiler if you build your own. I have yet to build
Perl successfully on Solaris with their default cc.
Regards,
Dan
------------------------------
Date: 21 Nov 2001 08:32:54 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: HELP: buggy regexp again....
Message-Id: <9tform$9s1$1@wanadoo.fr>
Hello!
again i have some problem with my regexps....
my incoming lines are diversely formatted but roughly of this schema:
some directories:
Fruit Basket
infinite ryvius
Kemzenak
and some files
02-still_rain-asx.mp3 (6.35 MB)
anything_not_in_folders_is_incomplete (0 B)
sweet_november.avi (60.00 kB)
infinite_ryvius_-_06.avi 158371840b
etc....
and as you may have guessed i want to detect the lines specifying a file
(having a size info at the end) and then remove that last part...
so i set up the following regexp:
if($line =~ /\d+( ?b| ?k| ?kb| ?mb)\s*$/i ||
$line =~ /\(\s*\d+\s*b|k|kb|mb\)$/i)
which works fine in most cases, but somehow lines as
Fruit Basket
Kemzenak
slip through and are tagged as files, making me completely astonished,
since IMHO they are far from beeing able to be matched by the
regexp...
Since i am at it, performance speaking, what's better, making hughe
regexps separated by '|' or make an array with the regexps and loop over
that one?
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Wed, 21 Nov 2001 09:48:54 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: HELP: buggy regexp again....
Message-Id: <9tfppm$20k$04$1@news.t-online.com>
On 21 Nov 2001 08:32:54 GMT, Bruno Boettcher wrote:
[...]
> 02-still_rain-asx.mp3 (6.35 MB)
> anything_not_in_folders_is_incomplete (0 B)
> sweet_november.avi (60.00 kB)
> infinite_ryvius_-_06.avi 158371840b
>
> etc....
> and as you may have guessed i want to detect the lines specifying a file
> (having a size info at the end) and then remove that last part...
Perhaps you are lucky and your filenames don't contain spaces in which
case you could comfortably get away with substr and index:
my $string = "infinite_ryvius_-_06.avi 158371840b"
$string = substr $string, 0, index $string, " ";
print $string;
__END__
infinite_ryvius_-_06.avi
Wrap that into an if-statement as you did below to check that you are
substringing the correct lines.
> if($line =~ /\d+( ?b| ?k| ?kb| ?mb)\s*$/i ||
Tassilo
--
When you go into court you are putting your fate into the hands of twelve
people who weren't smart enough to get out of jury duty.
-- Norm Crosby
------------------------------
Date: 21 Nov 2001 09:09:43 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: HELP: buggy regexp again....
Message-Id: <slrn9vmupm.n27.bernard.el-hagin@gdndev25.lido-tech>
On 21 Nov 2001 08:32:54 GMT, Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
> Hello!
>
> again i have some problem with my regexps....
>
> my incoming lines are diversely formatted but roughly of this schema:
[snipped sample data]
> etc....
> and as you may have guessed i want to detect the lines specifying a file
> (having a size info at the end) and then remove that last part...
>
> so i set up the following regexp:
> if($line =~ /\d+( ?b| ?k| ?kb| ?mb)\s*$/i ||
> $line =~ /\(\s*\d+\s*b|k|kb|mb\)$/i)
The reason this doesn't work is precedence.
> which works fine in most cases, but somehow lines as
> Fruit Basket
> Kemzenak
>
> slip through and are tagged as files, making me completely astonished,
> since IMHO they are far from beeing able to be matched by the
> regexp...
For your sample data the following works, but may break if your
real data differs:
$line =~ m/[0-9.]+ *[kbm]*\)?$/i
> Since i am at it, performance speaking, what's better, making hughe
> regexps separated by '|' or make an array with the regexps and loop over
> that one?
use Benchmark;
Cheers,
Bernard
------------------------------
Date: 21 Nov 2001 12:30:41 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: Re: HELP: buggy regexp again....
Message-Id: <9tg6ph$igd$1@wanadoo.fr>
>use Benchmark;
yeah that does it indeed :D thanks :D
and i am quite astonished by the difference:
Benchmark: timing 1000000 iterations of loop, ored test...
loop: 654 wallclock secs (641.35 usr + 2.59 sys = 643.94 CPU) @ 1552.94/s (n=1000000)
ored test: 112 wallclock secs (111.03 usr + 0.40 sys = 111.43 CPU) @ 8974.24/s (n=1000000)
Rate loop ored test
loop 1553/s -- -83%
ored test 8974/s 478% --
i programmed the worst case, the hit beeing allways the last pattern
but i ma not quite used to benchmark, the percentages on the last lines
are a bit hermetic to me....
since 8974/1553 = 5.778 = 577.8 % or for the inverse:
17.3% ....
so i see that the ored regexp is way faster than putting the thing into
an array and loop over it, but nothing more (i mean its allready ok that
way :D)
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Wed, 21 Nov 2001 11:25:11 GMT
From: John Smith <nospam@newsranger.com>
Subject: How to split variable length row
Message-Id: <raMK7.32710$xS6.55566@www.newsranger.com>
Hi perl gurus,
I need to split a comma seperated string into tokens.
For eg, a,b,c,d,e should
go into an array of a
b
c
d
e
I could have used split easily, but the only problem is that
the string is not fixed.
One string can be a,b,c,d and the other a,b
Without knowing the number of fields to be split in advance, I can't use
split function. Am I right?
This is what I have done:-
while (1) {
my $fulllen = length($dblist);
my ($dbl) = split(',',$dblist);
if ( ! defined($dbl) ) {
last ;
}
push @dblistf, $dbl ;
my $len = length($dbl);
my $rest=substr($dblist,$len+1,$fulllen);
$dblist = $rest ;
}
Basically I am taking one field at a time, truncating the string
one by one till all fields are taken out.
The above works clean, but something tells me that there
should be a better apporach in perl. Can anyone help me.
------------------------------
Date: 21 Nov 2001 11:38:35 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: How to split variable length row
Message-Id: <slrn9vn7gp.n27.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 21 Nov 2001 11:25:11 GMT, John Smith <nospam@newsranger.com> wrote:
> Hi perl gurus,
>
> I need to split a comma seperated string into tokens.
> For eg, a,b,c,d,e should
> go into an array of a
> b
> c
> d
> e
>
> I could have used split easily, but the only problem is that
> the string is not fixed.
> One string can be a,b,c,d and the other a,b
> Without knowing the number of fields to be split in advance, I can't use
> split function. Am I right?
You are wrong.
> This is what I have done:-
> while (1) {
> my $fulllen = length($dblist);
> my ($dbl) = split(',',$dblist);
> if ( ! defined($dbl) ) {
> last ;
> }
> push @dblistf, $dbl ;
> my $len = length($dbl);
> my $rest=substr($dblist,$len+1,$fulllen);
> $dblist = $rest ;
> }
>
> Basically I am taking one field at a time, truncating the string
> one by one till all fields are taken out.
> The above works clean, but something tells me that there
> should be a better apporach in perl. Can anyone help me.
You'll laugh, but all you have to do is:
my @dblistf = split /,/, $dblist;
Please read the docs on split:
perldoc -f split
Cheers,
Bernard
------------------------------
Date: 21 Nov 2001 11:42:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to split variable length row
Message-Id: <9tg3ue$r0t$2@mamenchi.zrz.TU-Berlin.DE>
According to John Smith <nospam@newsranger.com>:
> Hi perl gurus,
>
> I need to split a comma seperated string into tokens.
> For eg, a,b,c,d,e should
> go into an array of a
> b
> c
> d
> e
>
> I could have used split easily, but the only problem is that
> the string is not fixed.
> One string can be a,b,c,d and the other a,b
> Without knowing the number of fields to be split in advance, I can't use
> split function. Am I right?
[code snipped]
No. What makes you think so?
my @dblistf = split /,/, $dblist;
That's it.
Anno
------------------------------
Date: Wed, 21 Nov 2001 17:48:07 +0700
From: Antonius Herry Sukardi <asukardi@hns.co.id>
Subject: installing DBD::mysql on linux
Message-Id: <3BFB8667.D69B4640@hns.co.id>
Hi,
Currently I am trying to get perl (ver. 5.00503) working with MySQL
(ver. 3.23.43) on a linux (RH 6.2) server. I have installed both the
server and client part of mysql and even created a database there. Then
I installed the perl modules that came with the RH 6.2. I tested the
perl by running simple scripts and seems to be working normally. Now I
try to make perl script which is able to talk to mysql. I ran the CPAN
commands: perl -MCPAN -e 'install DBI'. It ran to completion and I
didn't see any error messages. Then I ran the perl -MCPAN -e 'install
DBD::mysql' This was where the problem started. After running awhile it
said that:
can't exec "mysql_config": No such file or directory at Makefile.PL line
168
Failed to determine directory of mysql.h
I search the entire server for mysql_config or mysql.h files, but it
doesn't seem to exist in my computer. Did I install the MySQL wrongly,
or am I missing something ?
I am not sure where the problem lies. Is it on the perl or is it on the
MySQL side. Can anybody please help, or point me to the right direction
?
Thanks
------------------------------
Date: Wed, 21 Nov 2001 13:26:39 GMT
From: Zoltan Kandi <zoltan.kandi@tellabs.com>
Subject: IO::Select and IO::Socket question: multiple connections
Message-Id: <3BFBB8A2.92FAD800@tellabs.com>
Dear All,
I am developing an application, which listens to the incoming messages
from several (up to 20) Windows NT servers running a proprietary NMS
over a TCP-IP connection.
This is the "listening" application:
> use strict;
> use IO::Socket;
> use IO::Select;
>
> my $new_client = new IO::Socket::INET (
> LocalHost => '192.168.13.167',
> LocalPort => '7071',
> Proto => 'tcp',
> Listen => 16,
> Reuse => 1,
> );
>
> my ($read_handle,$read_set,@read_handle_set,$new_socket,$buf);
>
> $read_set = new IO::Select();
> $read_set->add($new_client);
>
> while (@read_handle_set = $read_set->can_read)
> {
>
> foreach $read_handle (@read_handle_set)
> {
> if ($read_handle == $new_client)
> {
> $new_socket = $read_handle->accept();
> $read_set->add($new_socket);
> }
> else
> {
> $buf = <$read_handle>;
> if ($buf)
> {
> print $buf;
> }
> else
> {
> $read_set->remove($read_handle);
> close($read_handle);
> }
> }
> }
> }
> 1;
>
and this is the test script I run on several PCs to test the first one:
> #!/etc/bin/perl -w
> use strict;
> use IO::Socket;
> my $sock = new IO::Socket::INET ( PeerAddr => '192.168.13.167', PeerPort => '7071', Proto => 'tcp');
> die "Could not create socket: $!\n" unless $sock;
> print $sock 'hello there!\n';
> close($sock);
> 1;
Maybe the script are not optimal, but this works perfectly.
What I do miss is to be able to identify which client has sent which
message. So what I want to do is as a new socket is created, it should
be assigned some ID - I'm not sure a file or IO handle can be used as a
hash key! What solution could you recommend?
Thanks in advance and best regards,
Zoltan Kandi, M. Sc.
Product & Application Specialist
Tellabs Netherlands BV
Perkinsbaan 17
3439 ND Nieuwegein
Tel: +31 30 600 40 75
Fax: +31 30 600 40 90
GSM: +31 651 194 291
Email: Zoltan.Kandi@tellabs.com
Internet: http://www.tellabs.com
------------------------------
Date: Wed, 21 Nov 2001 13:38:11 GMT
From: Zoltan Kandi <zoltan.kandi@tellabs.com>
Subject: IO::Select and IO::Socket question: multiple connections
Message-Id: <3BFBBB55.31DEA81F@tellabs.com>
Dear All,
I am developing an application, which listens to the incoming messages
from several (up to 20) Windows NT servers running a proprietary NMS
over a TCP-IP connection.
This is the "listening" application:
> use strict;
> use IO::Socket;
> use IO::Select;
>
> my $new_client = new IO::Socket::INET (
> LocalHost => '192.168.13.167',
> LocalPort => '7071',
> Proto => 'tcp',
> Listen => 16,
> Reuse => 1,
> );
>
> my ($read_handle,$read_set,@read_handle_set,$new_socket,$buf);
>
> $read_set = new IO::Select();
> $read_set->add($new_client);
>
> while (@read_handle_set = $read_set->can_read)
> {
>
> foreach $read_handle (@read_handle_set)
> {
> if ($read_handle == $new_client)
> {
> $new_socket = $read_handle->accept();
> $read_set->add($new_socket);
> }
> else
> {
> $buf = <$read_handle>;
> if ($buf)
> {
> print $buf;
> }
> else
> {
> $read_set->remove($read_handle);
> close($read_handle);
> }
> }
> }
> }
> 1;
>
and this is the test script I run on several PCs to test the first one:
> #!/etc/bin/perl -w
> use strict;
> use IO::Socket;
> my $sock = new IO::Socket::INET ( PeerAddr => '192.168.13.167', PeerPort => '7071', Proto => 'tcp');
> die "Could not create socket: $!\n" unless $sock;
> print $sock 'hello there!\n';
> close($sock);
> 1;
Maybe the script are not optimal, but this works perfectly.
What I do miss is to be able to identify which client has sent which
message. So what I want to do is as a new socket is created, it should
be assigned some ID - I'm not sure a file or IO handle can be used as a
hash key! What solution could you recommend?
My second question:
Since the NMS application on the NT machines is running as a service,
it's not capable of setting up the necessary TCP/IP connection towards
my application, on the contrary, my app will have to set up a telnet
connection towards the NMS, log in, and only after a successful login
will be able to accept incoming packages. How do I set up this type of
connection?
I've tried
> my $new_client = new IO::Socket::INET (
> PeerAddr => '192.168.13.166',
> PeerPort => '4001', # IP address and port of one
> # of the servers
> # I've got 20 of them!
> LocalHost => '192.168.13.167',
> LocalPort => '7071',
> Proto => 'tcp',
> Listen => 16,
> Reuse => 1,
> );
but it does not seem to work at all.
Thanks in advance and best regards. Excuses for the long posting.
Zoltan Kandi, M. Sc.
Product & Application Specialist
Tellabs Netherlands BV
Perkinsbaan 17
3439 ND Nieuwegein
Tel: +31 30 600 40 75
Fax: +31 30 600 40 90
GSM: +31 651 194 291
Email: Zoltan.Kandi@tellabs.com
Internet: http://www.tellabs.com
------------------------------
Date: Wed, 21 Nov 2001 22:53:22 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Just wondering ... why is there no "since" information in the man pages?
Message-Id: <slrn9vn5di.mfo.mgjv@martien.heliotrope.home>
On Wed, 21 Nov 2001 09:28:47 +0100,
Edwin Günthner <edgue@web.de> wrote:
>
>
> Martien Verbruggen wrote:
>
>> I am not too certain about that. I fear that too many historical notes
>> in the documentation could make it harder to parse/follow.
>
> Do you really think it would be sooo confusing to have a special
> section "feature history" in the end of the document, looking like:
>
> * introduced in perl 5.0551
> * semantic change in ...
> * semantic change in ...
At the end of the document? sure. But that was not what we were talking
about. If it's at the end of the document, it may as well be in a
separate document. And we have that. it's the perl*delta.pod series of
documents.
> That would allow me to rely on the newest documentation - otherwise
> I have to scan the official delta logs (maybe PLUS the old/new
> documentation
> for a feature if its not mentionend in the main delta log).
Perl 5.6.x comes with three delta documents, perldelta, perl5005delta
and perl5004delta. They give a reasonably good summary of what changed.
I never find it too much trouble to scan them when I'm interested.
I'm sorry, but I just do not see enough value in the idea of a histor
_in_ the current documentation for it to be worth the amount of work
that would need to be done. We can keep arguing about that until we're
blue in the face, but I'm not going to change my mind.
>> Nope. And I guess that I also rely on my own historical knowledge of
>> Perl. I generally know when I'm writing code that certain
>> constructions, keywords and syntax is only available in version x.y
>> and above.
>
> Works fine - if you have this historical knowledge. Some people dont
> have it.
And for them there's perldelta.
> Maybe it would be a good solution to simply add a link at the bottom of
> each doc - pointing to a big, messy file holding the kind of information
> that you came up with here.
perldelta!
I've given my arguments on this. End of thread for me.
Martien
--
|
Martien Verbruggen | That's not a lie, it's a terminological
| inexactitude.
|
------------------------------
Date: Wed, 21 Nov 2001 09:28:47 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: Just wondering ... why is there no "since" information in the man pages?
Message-Id: <3BFB65BF.A13E3670@web.de>
Martien Verbruggen wrote:
> I am not too certain about that. I fear that too many historical notes
> in the documentation could make it harder to parse/follow.
Do you really think it would be sooo confusing to have a special
section "feature history" in the end of the document, looking like:
* introduced in perl 5.0551
* semantic change in ...
* semantic change in ...
That would allow me to rely on the newest documentation - otherwise
I have to scan the official delta logs (maybe PLUS the old/new
documentation
for a feature if its not mentionend in the main delta log).
> Nope. And I guess that I also rely on my own historical knowledge of
> Perl. I generally know when I'm writing code that certain
> constructions, keywords and syntax is only available in version x.y
> and above.
Works fine - if you have this historical knowledge. Some people dont
have
it.
> Yes, but the documentation, as it is (also see my other post on this)
> is not very well suited for these interjections. perlfunc, perlvar and
> maybe parts of perlre could be most easily documented historically,
> but perlsyn, perldata and perlop would be very hard to do.
And so - because we can't do it for all of our children - we will
not do it for any of them?
> Besides that, features don't only get added, they get changed and
> deprecated. delete didn't use to work on slices. flock didn't always
> automatically flush a file handle on an unlock. keys %hash wasn't
> always an lvalue. The various formats for pack weren't always there.
Again, my point is: you know all these things - even if you forgot
them ... as soon as you are writing and testing code for a specific
version and its not doing what it is supposed to do - you might
remember after 20 minutes or so "uups, flock had another behaviour
in that old version".
I have never used flock before. For me it would be HARD to find out
that its behaviour has changed. Of course I might find out this fact -
if it is mentioned in the documentation by chance.
> As I said in another post: I think perl is just too organic to
> decently incorporate all this, historically, in the documentation
> itself.
Thats a valid the point.
> True. I guess I'm just biased towards keeping this sort of information
> out of the documentation, mainly because I don't need it in the
> documentation. There aren't many times that I need to check the
> documentation to find out when a feature became available.
Maybe it would be a good solution to simply add a link at the bottom of
each doc - pointing to a big, messy file holding the kind of information
that you came up with here.
Of course that would mean a lot of work for the maintainer of this
document - but I think that it would be really helpful in a lot of
ways.
regards,
eg
------------------------------
Date: 21 Nov 2001 04:29:09 -0800
From: u8526505@ms27.hinet.net (derek chen)
Subject: LWP::UserAgent Post & Session problem
Message-Id: <85789064.0111210429.451df286@posting.google.com>
I used post method to request a page and got a redirect address which
is embedded in the $response->content.So I extracted it and did the
request again.
Since these are different sessions for server so all the data posted
in the first session were gone.What can I do to solve this problem
just like a browser does.Thanks.
Derek
------------------------------
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.
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 2169
***************************************