[17969] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 129 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 24 00:05:39 2001

Date: Tue, 23 Jan 2001 21:05:12 -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: <980312712-v10-i129@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 23 Jan 2001     Volume: 10 Number: 129

Today's topics:
    Re: ActiveState and Tk <bowman@montana.com>
    Re: Benchmark For ActiveState Win32 <godzilla@stomp.stomp.tokyo>
        Benchmark: Test Code Syntax Error <godzilla@stomp.stomp.tokyo>
    Re: Benchmark: Test Code Syntax Error <chrisw@dynamite.com.au>
    Re: Benchmark: Test Code Syntax Error <godzilla@stomp.stomp.tokyo>
    Re: Benchmark: Test Code Syntax Error <godzilla@stomp.stomp.tokyo>
    Re: Benchmark: Test Code Syntax Error <johngros.NOSPAM@bigpond.net.au>
    Re: Benchmark: Test Code Syntax Error <chrisw@dynamite.com.au>
    Re: Benchmark: Test Code Syntax Error <godzilla@stomp.stomp.tokyo>
    Re: Benchmark: Test Code Syntax Error <chrisw@dynamite.com.au>
    Re: Benchmark: Test Code Syntax Error <godzilla@stomp.stomp.tokyo>
    Re: Benchmark: Test Code Syntax Error <chrisw@dynamite.com.au>
    Re: bidirectional communication using sockets <ehsan.cheema@cis.canon.com>
    Re: Borland Paradox db dumper <jhelman@wsb.com>
    Re: Catching warnings from Getopt::Std (Garry Williams)
    Re: CHECK CHILD (Garry Williams)
    Re: ERROR: Bad arg length for Socket <johngros.NOSPAM@bigpond.net.au>
    Re: FAQ 9.9:   How do I decode or create those %-encodi <iltzu@sci.invalid>
        formmail script not printing all fields <vanced@ohsu.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 23 Jan 2001 19:29:27 -0700
From: "bowman" <bowman@montana.com>
Subject: Re: ActiveState and Tk
Message-Id: <F6rb6.9617$d25.61713@newsfeed.slurp.net>


<zatlas@juno.com> wrote in message news:94konv$emo$1@nnrp1.deja.com...
>
> I installed the latest ActivePerl, ActivePython and  and ActiveState
Komodo
> IDE (Beta 1.0) and I can't find neither PerlCRT.lib nor PerlCRT.lib.  When
I
> compile the statement use Tk; I get: "Can't locate Tk.pm in @INC (@INC
> contains: C:\Program

I don't believe the Tk module is included in the ActiveState Perl distro.
Use ppm to get it.
Also, Tcl/Tk 8.3 is a separate download and install if you wish ot use
Tkinter.





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

Date: Tue, 23 Jan 2001 15:09:22 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark For ActiveState Win32
Message-Id: <3A6E0F22.5A616A96@stomp.stomp.tokyo>

Chris W wrote:
 
> Godzilla! wrote:

> > Any work-around available for installing a
> > benchmark module under ActiveState 5.6
> > for Win32?
 
> You mean other than the Benchmark module that's
> a standard part of the distribution (Build 623) ?


Thank you Chris! I just visited ActiveState and
they do have a new version out now, this build
623 you mention. I will download this latest
version. No problems now on trying to install
a benchmark module.

Thank you again Chris. Your information has
completely resolved my problem with one mouse
click ease. This is so nice.

Godzilla!


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

Date: Tue, 23 Jan 2001 17:51:54 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Benchmark: Test Code Syntax Error
Message-Id: <3A6E353A.F0107D1A@stomp.stomp.tokyo>

I've been teaching myself how to use the benchmark
module under ActiveState build 623 - Win32. My luck
has been very good with simple test scripts, hello 
world type prints and similar. I was able to benchmark
a more complex script which uses a hash displayed in
closing. However, I have run into a problem with the
foreach function I cannot seem to resolve regardless
of numerous and varied syntax changes.

This is my exact benchmark test script:

#!perl -w
use Benchmark;
timethis (1000000,
@Array1 = qw (a:EH b:BEE c:SEE),
$string = "abc",
@Array2 = split (//, $string),
foreach $array1 (@Array1)
 {
  ($in, $out) = split (/:/, $array1),
  foreach $array2 (@Array2)
   {
    if ($array2 eq $in)
     { print $out, }
   }
 })


I am receiving this error message:

syntax error at bench2.pl line 7, near "foreach "

line 7 is:  foreach $array1 (@Array1)

This script runs ok as a stand-alone with
correct semicolon syntax in place of
benchmark commas. Zero problems. However,
as a benchmark test script, blah! Crashes.

What is my syntax error regarding benchmark?
Is it the comma in the split just prior to foreach?
If so, what syntax should I use for a split?

* wonders why commas are used instead of semicolons *

This script, similar to above but using a hash,
runs perfect as a benchmark test script. My logic
is ok but the foreach function syntax error is 
boogering my mind more than it is normally.

This is my exact second benchmark test script:

#!perl -w
use Benchmark;
timethis (1000000,
%translation = (a => "EH",  b => "BEE",  c => "SEE"),
$string = "abc",
$string =~ s/([a-z])/$translation{$1} /g,
print $string)

What is getting me, my hash contains commas in this
second script, my split in my first script contains
a comma, but what is the relationship, the error?

Any help is appreciated.

Godzilla!


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

Date: Wed, 24 Jan 2001 13:36:25 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <jerb6.65$Q82.2928@news0.optus.net.au>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3A6E353A.F0107D1A@stomp.stomp.tokyo...
[snip]
> closing. However, I have run into a problem with the
> foreach function I cannot seem to resolve regardless
> of numerous and varied syntax changes.
>
> This is my exact benchmark test script:
>
> #!perl -w
> use Benchmark;
> timethis (1000000,
> @Array1 = qw (a:EH b:BEE c:SEE),
> $string = "abc",
> @Array2 = split (//, $string),
> foreach $array1 (@Array1)
>  {
>   ($in, $out) = split (/:/, $array1),
>   foreach $array2 (@Array2)
>    {
>     if ($array2 eq $in)
>      { print $out, }
>    }
>  })

I can't see which of the possible syntaxes you are attempting to use for the
timethis call.   The following code snippet works:

Your code is a string (quoted inside q{ }) and the commas are semicolons
where appropriate:

#!perl -w
use Benchmark;
timethis (1000, q{
 @Array1 = qw (a:EH b:BEE c:SEE);
 $string = "abc";
 @Array2 = split (//, $string);
 foreach $array1 (@Array1) {
  ($in, $out) = split (/:/, $array1);
  foreach $array2 (@Array2) {
   if ($array2 eq $in)
   { print $out; }
  }
 }
}
);

Alternatively using a code reference:

#!perl -w
use Benchmark;
timethis (1000, sub {
 @Array1 = qw (a:EH b:BEE c:SEE);
 $string = "abc";
 @Array2 = split (//, $string);
 foreach $array1 (@Array1) {
  ($in, $out) = split (/:/, $array1);
  foreach $array2 (@Array2) {
   if ($array2 eq $in)
   { print $out; }
  }
 }
}
);


> * wonders why commas are used instead of semicolons *

I'm not sure where you got this idea from.   There are some functions in
Benchmark that take a hash reference, perhaps these were confusing the
issue.

> This is my exact second benchmark test script:
>
> #!perl -w
> use Benchmark;
> timethis (1000000,
> %translation = (a => "EH",  b => "BEE",  c => "SEE"),
> $string = "abc",
> $string =~ s/([a-z])/$translation{$1} /g,
> print $string)

Same problem as the first script.

Hope this helps.




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

Date: Tue, 23 Jan 2001 19:18:23 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <3A6E497F.C8757383@stomp.stomp.tokyo>

Chris W wrote:
 
> Godzilla! wrote:

> [snip]

> > closing. However, I have run into a problem with the
> > foreach function I cannot seem to resolve regardless
> > of numerous and varied syntax changes.

> > This is my exact benchmark test script:

(snipped)

> I can't see which of the possible syntaxes you are attempting to
> use for the timethis call.   The following code snippet works:
 
> Your code is a string (quoted inside q{ }) and the commas are semicolons
> where appropriate:
 
(snipped code)

> Alternatively using a code reference:
 
(snipped code)

> > * wonders why commas are used instead of semicolons *
 
> I'm not sure where you got this idea from.   There are some functions in
> Benchmark that take a hash reference, perhaps these were confusing the
> issue.
 
(more snippage)

Thank you again Chris! As you can read, I followed
your suggestion and downloaded build 623 to attain
the benchmark module as a binary install. It works!

On the commas in place of semicolons, build 623 shows
commas in the documentation for benchmark, or the author
shows commas in place of semicolons. Look at his usage
and his examples.

Odd though, I did a copy and paste of his examples given
with his benchmark documentation. Not surprising, his
examples crash with syntax errors. Well, I tried one
and it crashed so I didn't bother with his other examples.

I tried some scripts with semicolons as should be, and
benchmark crashes. Changing those semicolons to commas,
a benchmark test script runs fine. My suspicion is the
author of this benchmark module with build 623 has made
some errors in his documentation, is not a very good
writer, or the module itself has some bugs. Personal
guess on what is wrong; who knows?

There is another possibility. When I read, I take
everything literally; precise and exact. Perhaps
he is using those commas as "commas" in writing
and not as syntax commas. This is always a problem
with technical journalists; they are journalists
and not writers often forgetting punctuation in
writing is also syntax in programming. Still,
there is this problem of his examples crashing
and my changing semicolons to commas, then
having success. This annoys me; it's confusing.

I strongly suspect, though, this author of this 
benchmark module is a piss poor writer and his 
documentation is seriously flawed.

I have copied your techniques and will run them here in
a bit and learn what happens, then report back. Might
be awhile, chances are good I will play around with
syntax to develop a better feel for overcoming whatever
these problems are with the benchmark module, author
mistakes in documentation or bugs in a his program.

I will run your syntax and, I am sure it will work. 
Chances are good I will have luck with your q{} syntax
which helps by retaining original semicolons in code;
easier to copy and paste. Once I have success with
this method, then I will give your sub{} syntax a
good try. After testing and success, I believe I shall
sit and write a stern letter to the author of this
benchmark module, advising him to get his act together,
take a Bonehead English class and learn how to write
clearly and concisely. Adding insult to injury, I will
advise him those examples of his, crash and burn.

* growls *


Thank you again for your help! I will report back
later on what happened.

Godzilla!


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

Date: Tue, 23 Jan 2001 19:47:28 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <3A6E5050.5BAE8FA7@stomp.stomp.tokyo>

Chris W wrote:
 
> Godzilla! wrote:

(lots of snippage)

> I can't see which of the possible syntaxes you are attempting
> to use for the timethis call.   The following code snippet works:


> Alternatively using a code reference:


Hey Chris! Both of your syntax methods work fine!

I am so pissed off but, as a stereotypical woman,
no doubt I will get over this within ten years.

In part of the documentation for benchmark, the
author uses quote enclosure, "code" , for one
example. Later he doesn't use quote enclosure.
In some examples, he uses apostrophe enclosure,
this is single quotes and, other examples uses
a sub reference as you did. Adding to my annoyance,
is some examples, it appears he replaced semicolons
with commas! What crisped my cookies though is having
his own code examples crash and burn even with a
careful and precise copy and paste.

Anyhow, your methods work. I will experiment now
and see if I cannot do some serious benchmark work.

Be sure you understand your help is sincerely appreciated.
This is twice today you have helped me and, your advice
is right and precise in both cases.

* sigh of relief *

Gives me anxiety trying to figure out exactly what
many Perl documentation authors are trying to say.
This bad English technogeekster gibberish is enough
to drive this English teacher to taking prozac, again.
Even worse, all this technical doublespeak gobbullygook
written by .. well.. you know.. is enough to drive this
science teacher to taking a few swigs of her stockroom
wood grain alcohol, legally purchased of course.

It's the Moonshine from my cousins in Oklahoma which
is quite unlawful. However, easy to dispose of evidence.

Thank you so much, Chris. You have made my programming
day without doubt. Now I can benchmark code and become
more of a rebel rouser here. Heh!

I will give you feedback should I discover anything
out of the norm which may interest you.

Godzilla!


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

Date: Wed, 24 Jan 2001 04:01:05 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <5ssb6.79991$xW4.618066@news-server.bigpond.net.au>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3A6E497F.C8757383@stomp.stomp.tokyo...
> Chris W wrote:
>
> > Godzilla! wrote:
>
> > [snip]
>
> > > closing. However, I have run into a problem with the
> > > foreach function I cannot seem to resolve regardless
> > > of numerous and varied syntax changes.
>
> > > This is my exact benchmark test script:
>
> (snipped)
>
> > I can't see which of the possible syntaxes you are attempting to
> > use for the timethis call.   The following code snippet works:
>
> > Your code is a string (quoted inside q{ }) and the commas are semicolons
> > where appropriate:
Yeah as far as it goes but you have some typos in your code.
Which were not corrected. variable names are case sensitive @array1 and
@Array1 are different,
 ditto for @array2 and @Array2.
The two lines following your #! line need to be :
use diagnostics;
use strict;
And the next line then needs to be :
my ($var1, $var2, @array1, @array2, %hash1, %hash2);
# to declare variables you want global through your script.
After that any variables not already declared need to be declared before
use.





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

Date: Wed, 24 Jan 2001 15:02:34 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <Mvsb6.80$Q82.3180@news0.optus.net.au>

> Thank you again Chris! As you can read, I followed
> your suggestion and downloaded build 623 to attain
> the benchmark module as a binary install. It works!

Cool

> On the commas in place of semicolons, build 623 shows
> commas in the documentation for benchmark, or the author
> shows commas in place of semicolons. Look at his usage
> and his examples.

Not in my copy.   In the Examples section there are no examples for
timethis(), only cmpthese() and timethese() which take hash references (anon
hashes in the examples) and do indeed have commas between the key/value
pairs.   The syntax synopsis for timethis() is quite clear that CODE is a
string or code reference:

timethis ( COUNT, CODE, [ TITLE, [ STYLE ]] )
Time COUNT iterations of CODE. CODE may be a string to eval or a code
reference; either way the CODE will run in the caller's package. Results
will be ...

 > Odd though, I did a copy and paste of his examples given
> with his benchmark documentation. Not surprising, his
> examples crash with syntax errors.

The two examples do seem to be in error.  They assume that cmpthese() is
exported by default, which is not the case, but probably was at some time in
the past.   This has nothing to do with commas, but can be confusing to
learners.

> I strongly suspect, though, this author of this
> benchmark module is a piss poor writer and his
> documentation is seriously flawed.
[snip]
> I believe I shall
> sit and write a stern letter to the author of this
> benchmark module, advising him to get his act together,
> take a Bonehead English class and learn how to write
> clearly and concisely. Adding insult to injury, I will
> advise him those examples of his, crash and burn.

That's probably a little harsh.   The author of the module is a volunteer
who probably has other things to do with life.   It's easy enough to miss
things in documentation and it doesn't necessarily reflect malicious intent,
stupidity, or unprofessionalism.   There is no formal review process unless
the author wishes to, or has time to, run one prior to release.   By all
means write a _polite_ note to him or her and point out the deficiencies BUT
be sure they are deficiencies in the documentation or code and not
deficiencies in understanding beforehand.

Chris W








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

Date: Tue, 23 Jan 2001 20:10:14 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <3A6E55A6.5D37F29B@stomp.stomp.tokyo>

John Boy Walton wrote:
 
> Godzilla! wrote:
> > Chris W wrote:
> > > Godzilla! wrote:

> > > [snip]

> > > I can't see which of the possible syntaxes you are attempting to
> > > use for the timethis call.   The following code snippet works:

(snippage)

> Yeah as far as it goes but you have some typos in your code.
> Which were not corrected. variable names are case sensitive @array1 and
> @Array1 are different,
>  ditto for @array2 and @Array2.

I cannot find either of these examples. Perhaps your 
news reader is messing up?


> The two lines following your #! line need to be :
> use diagnostics;
> use strict;

These are not warranted for simple test scripts.
Use of those pragmas would serve no purpose and
would slow down the script and use more memory.
This code posted is too short, too simple, to
require a need for what you suggest.

> And the next line then needs to be :
> my ($var1, $var2, @array1, @array2, %hash1, %hash2);
> # to declare variables you want global through your script.
> After that any variables not already declared need to be declared before
> use.

No need to use my declarations for this. As I said, these
are short simple test scripts. Variable declarations,
either global or my, are truly irrelevant. Most of these
variables you list, are not included in my test scripts.

Perhaps you are responding to the wrong article???

Godzilla!


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

Date: Wed, 24 Jan 2001 15:08:24 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <kAsb6.81$Q82.2953@news0.optus.net.au>


"John Boy Walton" <johngros.NOSPAM@bigpond.net.au> wrote in message
news:5ssb6.79991$xW4.618066@news-server.bigpond.net.au...

> Yeah as far as it goes but you have some typos in your code.
> Which were not corrected. variable names are case sensitive @array1 and
> @Array1 are different,
>  ditto for @array2 and @Array2.
> The two lines following your #! line need to be :
> use diagnostics;
> use strict;
> And the next line then needs to be :
> my ($var1, $var2, @array1, @array2, %hash1, %hash2);
> # to declare variables you want global through your script.
> After that any variables not already declared need to be declared before
> use.

Good pickup.
I didn't try and validate what the code to be benchmarked was attempting to
do.
The suggestions regarding the diagnostics, strict (and use vars or my)
pragmas are worth far more than their typing time.





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

Date: Tue, 23 Jan 2001 20:17:13 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <3A6E5749.842036@stomp.stomp.tokyo>

Chris W wrote:

> > I strongly suspect, though, this author of this
> > benchmark module is a piss poor writer and his
> > documentation is seriously flawed.

> [snip]

> > I believe I shall
> > sit and write a stern letter to the author of this
> > benchmark module, advising him to get his act together,
> > take a Bonehead English class and learn how to write
> > clearly and concisely. Adding insult to injury, I will
> > advise him those examples of his, crash and burn.
 
> That's probably a little harsh.   The author of the module is a volunteer
> who probably has other things to do with life.   It's easy enough to miss
> things in documentation and it doesn't necessarily reflect malicious intent,
> stupidity, or unprofessionalism.   There is no formal review process unless
> the author wishes to, or has time to, run one prior to release.   By all
> means write a _polite_ note to him or her and point out the deficiencies BUT
> be sure they are deficiencies in the documentation or code and not
> deficiencies in understanding beforehand.


I am both an English teacher and an English professor.
Would you expect me to be less than Wicked Witch harsh?
Doesn't help my personality being a science teacher
as well. We expect precise perfection with clarity.

Heh!

I'll never write this guy. Most likely I will have an
"AH HA!" understanding in a few days and feel a fool.
Then I will write and chastise him for sure due to his
leading me to make a fool of myself even though my fault.

Isn't this how we are suppose to behave?

Thanks again for your help. I am psyched now.

Godzilla!


Hmm... I still believe technogeeksters can't write no how.


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

Date: Wed, 24 Jan 2001 15:32:04 +1100
From: "Chris W" <chrisw@dynamite.com.au>
Subject: Re: Benchmark: Test Code Syntax Error
Message-Id: <CWsb6.85$Q82.3239@news0.optus.net.au>

"Chris W" <chrisw@dynamite.com.au> wrote in message
news:kAsb6.81$Q82.2953@news0.optus.net.au...

> "John Boy Walton" <johngros.NOSPAM@bigpond.net.au> wrote in message
> news:5ssb6.79991$xW4.618066@news-server.bigpond.net.au...
>
> > Yeah as far as it goes but you have some typos in your code.
> > Which were not corrected. variable names are case sensitive @array1 and
> > @Array1 are different,
> >  ditto for @array2 and @Array2.

> Good pickup.

Crap Chris :}

On second inspection, these "errors" don't exist.   There are two arrays
@Array1 and @Array2, and two scalars $array1 and $array2, and never the two
shall meet.




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

Date: Tue, 23 Jan 2001 15:16:09 -0800
From: "Sean Blaire" <ehsan.cheema@cis.canon.com>
Subject: Re: bidirectional communication using sockets
Message-Id: <94l6nj$5ka$1@news.cis.canon.com>

Hello Sebastian,
I tried your client server program and this is the error message that I get:
Can't call method "recv" on an undefined value at <filename> line 14.

I am using Windows NT

any suggestions?

Sean

"Sébastien Cottalorda" <sebastien.cottalorda@mageos.com> wrote in message
news:94hcri$1huf$1@news4.isdnet.net...
> Hi,
>
> Here is a couple of perl script that works perfectly for me.
>
> CLIENT:
> #!c:\perl\bin\perl -w
> use IO::Socket;
> $socket = IO::Socket::INET->new(PeerAddr=> '190.197.10.217',
>     PeerPort=> '123456',
>     Proto=> "tcp",
>     Type=> SOCK_STREAM)
>  or die "Couln\'t connect to 190.197.10.217:123456 $@\n";
> $phrase = "How are you \?";
> $socket->send("$phrase"."FIN",'') or die "Can\'t send $!\n";
> print "> $phrase \n";
> $data_read='seb';
> ITER: while ($data_read) {
>      $socket->recv($data_read,'256') or die "Can\'t recv $!\n";
>      print "< $data_read \n" unless ($data_read=~/FIN/);
>      last ITER if ($data_read=~/FIN/);
> }
> $data_read=~s/FIN//;
> print "< $data_read \n";
> exit 0;
>
>
> SERVEUR:
> #!c:\perl\bin\perl -w
> use IO::Socket;
> use Carp;
> use POSIX qw(strftime);
> $port_recep='123456';
> $server= IO::Socket::INET->new(LocalPort=> $port_recep,
>     Type=> SOCK_STREAM,
>     Reuse=>1,
>     Listen=>10)
>  or die "Couln\'t be a tcp server on $port_recep $@\n";
> while ($client=$server->accept()) {
>      $data_read='seb';
>      ITER: while ($data_read) {
>           $client->recv($data_read,'256') or die "Can\'t recv $!\n";
>           print "< $data_read \n" unless ($data_read=~/FIN/);
>           last ITER if ($data_read=~/FIN/);
>      }
>      $data_read=~s/FIN//;
>      print "< $data_read \n";
>      $phrase = "I feel good thanks";
>      $client->send($phrase."FIN",'') or die "Can\'t send $!\n";
>      print "> $phrase \n";
> }
> exit 0;
>
> The principe:
> The client connect to the server and send pack of 256 bytes, when
finishing,
> it send the word "FIN". Then the client go into listenning position.
> The server listen a connection, open the socket, read 256 bytes packets
> until the reception of word "FIN" (you can choose what you want).
> then the server send the answer finishing with the word "FIN" (you can
> choose of course).
> The client record the server listening by pack of 256 bytes until the word
> "FIN".
> Then it close the connection.
>
> This is the first version of my program, I've then replaced "FIN" by "\r"
:
> Carriage Return
>
> BE VERY CAREFULL, it's very easy to make deadlock with that method :
Server
> listening and client listening too.
>
> Hope this helps.
>
> Sebastien
>
> <mmustafa@my-deja.com> a écrit dans le message :
> 942bgq$aj5$1@nnrp1.deja.com...
> > Hi,
> >    I am trying to write a PERL program using sockets. One side ( which
> > we call client ) is communicating with the listener ( which we call
> > server) thru a specific port. This is working fine.
> > The problem i am running into is after sending a couple of strings
> > (haven't been able to pass an array), the listener/ server reads it,
> > and does some processing. But if the listener wants to send some
> > response back to the client, the client can't read it. I will give a
> > brief code summnary here ( rather then the whole thing ) , this didn't
> > work :
> > CLIENT CODE :
> > #socket initializination, $port and $server are arguments
> > socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);
> > connect (SOCKET, pack('Sna4x8', AF_INET, $port,
> >         (gethostbyname($server))[4]))
> >         || die "Can't connect to server $server on port $port .\n";
> > SOCKET->autoflush();
> >
> >
> > print SOCKET "Command1 \r\n";
> > print SOCKET "Command2 \r\n";
> >
> > # I need to read response from the server :
> > # did NOT WORK
> > #       shutdown(SOCKET,1);
> > #       while (<SOCKET>) {
> > #       while (defined ($string = <SOCKET>) ) {
> >         recv(SOCKET,$string,100,0);
> >         if ($string) {
> >                 $string = $_;
> >                 print "STRING : ****($string)****\n";
> >                 if ($string == 1) {
> >
> >
> > I tried threading the process , which created further problems ( maybe
> > programing error).
> > I tried shutdown , which also on the server side, so that the client
> > doesn't keep on waiting ( according to the documentation , recv will
> > keep on waiting).
> >
> >
> > Here is a snippet of SERVER CODE :
> > $server = IO::Socket::INET->new( Proto     => 'tcp',
> >                                   LocalPort => $DEFAULT_PORT,
> >                                   Listen    => SOMAXCONN,
> >                                   Reuse     => 1);
> >
> > while(<$server>)
> >   {
> >         chomp($_);
> >         print "Value of i = $i and this is what I got
> >         from the other machine: **($_)** \n";
> >         autoflush $server 5;
> >         $i++;
> >         if ($i == 1) {
> >                 $input = $_ ;
> >                 chomp($input);
> >                 print "\tRELEASE OR DROP = ($input) \n";
> >         }
> >
> >
> > If anyone knows how to do it...  please post something....
> > I apologise if the message is cryptic or vague, I would love to explain
> > further if anyone has interest to help.
> >
> > Thanks a lot in advance
> > Farooq
> >
> >
> > Sent via Deja.com
> > http://www.deja.com/
>
>




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

Date: Wed, 24 Jan 2001 02:27:51 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Borland Paradox db dumper
Message-Id: <b9fs6to16c4ot46cuj0jqt30q2rd0r9fba@4ax.com>

On Tue, 23 Jan 2001 18:58:38 GMT, Paul Eckert <peckert@epicrealm.com>
wrote:

>Anybody have any idea where I can get a Paradox DBI module or perhaps a
>script to parse and/or dump Paradox database files to text?  

Since you don't mention an operating system, I'll assume some Win32
variant (as I don't know if Paradox runs on anything else).  If you
can define an ODBC driver for the database, you can access it using
the Win32::ODBC object and dump data to your hearts content.
Win32::ODBC is installed with the standard ActiveState distribution,
so the documentation for the module resides on your hard drive.  Give
it a try.

If you aren't using Win32, then disregard the above.

Hope this helps,
JH



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

Date: Wed, 24 Jan 2001 03:32:42 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <u1sb6.150$GF2.6376@eagle.america.net>

On Tue, 23 Jan 2001 15:12:42 +0000, James Taylor
<james@NOSPAM.demon.co.uk> wrote:
>In article <zUgb6.22$GF2.1369@eagle.america.net>, Garry Williams
><URL:mailto:garry@zvolve.com> wrote:
>> 
>> The getopts() function also returns false.
>> Check it, if you want to know.
>
>Interesting. Under what conditions exactly does it return false?
>
>The getopts() return value is not documented, at least not in the
>documentation I have. I would be reluctant to rely on an undocumented
>feature because it might change in the future.

Yes, I noticed that, too.  I wanted to point you to the manual page,
but it didn't document the behavior.  I seem to remember either an
earlier version of the manual page or the Camel that *did* document
the fact that an unknown switch would cause getopts() to return false.
I have always relied on that.  

  sub USAGE () { die "usage: ..."; }
  getopts('ab:') || USAGE;

I checked perl 5.004_05 but it was the same as 5.6.0.  I must remember
the Camel, second edition.  I'll check tomorrow.  

>Looking through the code of Getopt::Std there is no explicit use of
>return so I assume from that that the return value is not a well
>established thing.

Okay, I looked at the code, too.  There *is* an explicit return of a
truth value in the getopts() subroutine.  It's the last statement in
the subroutine and there is no explicit return() in the subroutine.
That is consistent with its documented behavior of "consuming" the
options from @ARGV.  In other words, the scan shifts all of the
options off of @ARGV, leaving any non-options and it "notes" any
errors as it goes.  This is the last statement of the subroutine: 

    $errs == 0;

So, the code guarantees that any invalid option scanned will result in
a false value returned to the caller of getopts().  This is *not* the
case with the getopt() subroutine.  

It's a shame that the manual page does not document this obviously
deliberate behavior.  

-- 
Garry Williams


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

Date: Wed, 24 Jan 2001 04:05:11 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: CHECK CHILD
Message-Id: <Xvsb6.154$GF2.6376@eagle.america.net>

On Tue, 23 Jan 2001 13:10:27 -0800, GOGAR <angenent@kabelfoon.nl> wrote:
>From: "Garry Williams" <garry@zvolve.com>
>> On Tue, 23 Jan 2001 06:39:29 -0800, GOGAR <angenent@kabelfoon.nl> wrote:
>> >Anybody knows how to see if a fork()'ed child process is still there?
>> >thanx
>>
>> print "alive" if kill 0, $pid;
>
>
>Actually i tried that, and it always seems to return 1  but looking at the
>NT task manager i can see the Thread terminated.

Oh, NT.  I have no idea how to answer your question.  Sorry.  

-- 
Garry Williams


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

Date: Wed, 24 Jan 2001 03:35:57 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: ERROR: Bad arg length for Socket
Message-Id: <x4sb6.79959$xW4.617877@news-server.bigpond.net.au>


<jce2000@my-deja.com> wrote in message news:94h1ht$6pi$1@nnrp1.deja.com...
> Hi,
>
>   I write a little perl program using Net::FTP and I receive this
> message:
>
>   Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be
> 16 at /usr/lib/perl5/5.00503/i386-linux/Socket.pm line 295.
The value you pass to Socket:unpack_sockaddr_in is undef. Trace its source
and find where you think you are assigning it a value but are not. I make
these errors all the time. (Asssigning a value incorrectly) ;-(




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

Date: 23 Jan 2001 23:10:30 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: FAQ 9.9:   How do I decode or create those %-encodings on the web?
Message-Id: <980287608.25633@itz.pp.sci.fi>

In article <hY4b6.1214$B9.193615872@news.frii.net>, PerlFAQ Server wrote:
>+
>  How do I decode or create those %-encodings on the web?
>
>    Here's an example of decoding:
>
>        $string = "http://altavista.digital.com/cgi-bin/query?pg=q&what=news&fmt=.&q=%2Bcgi-bin+%2Bperl.exe";
>        $string =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;
>
>    Encoding is a bit harder, because you can't just blindly change all the
>    non-alphanumunder character (`\W') into their hex escapes. It's
>    important that characters with special meaning like `/' and `?' *not* be
>    translated. Probably the easiest way to get this right is to avoid
>    reinventing the wheel and just use the URI::Escape module, available
>    from CPAN.
>
>- 

This is just.. wrong.  Even the technically correct bits *feel* wrong.

 1. The words "a bit harder" are an understatement.  It is actually
    *impossible* to encode an URI after its component parts have been
    joined together, according to both RFC2396 and common sense.

 2. The converse, in fact, applies to decoding, at least unless you
    want to lose information.

 3. Pointing newbies at URI::Escape, without noting that the default
    list of escaped characters in that module is a half-assed mutant
    hack fit for no particular purpose, is IMHO irresponsible.

What should it say then?

 * First of all, it should point to CGI.pm.  If you want to "decode
   those %-encodings" than most likely you're dealing with a CGI query
   string.  Even if you aren't, it may still be useful.

 * Second, it should point to RFC 2396.  It's one of the most readable
   RFCs out there, and the answers in it are hard to beat in clarity.

 * The encoding and decoding regexen should probably be shown, but
   _not_ in context, since there isn't a general one.  It should be
   explicitly mentioned that they should only be used on isolated URI
   componenents.

=pod

=head2 How do I decode or create those %-encodings on the web?

If you are writing a CGI script, you should be using the CGI.pm module
that comes with perl, or some other equivalent module.  The CGI module
automatically decodes queries for you, and provides an escape()
function to handle encoding.

The best source of detailed information on URI encoding is RFC 2396.
Basically, the following substitutions do it:

    s/([^\w()'*~!.-])/sprintf '%%%02x', $1/eg;   # encode

    s/%([A-Fa-f\d]{2})/chr hex $1/eg;            # decode

However, you should only apply them to individual URI components, not
the entire URI, otherwise you'll lose information and generally mess
things up.  If that didn't explain it, don't worry.  Just go read
section 2 of the RFC, it's probably the best explanation there is.

RFC 2396 also contains a lot of other useful information, including a
regexp for breaking any arbitrary URI into components (Appendix B).

=cut

Hmm.. it did gain a bit of length.  But I'd really like to make it
obvious that the RFC is the place to look, since so many people seem
to be somehow afraid of them.  Still, perhaps someone else might be
able to suggest ways to make it shorter.

[Posted and mailed.]

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"And I think I've probably failed to express the thing I'm trying to say, but
 I'll send this version, and when people object to it I might figure out words
 I really needed to use to say it."  -- Lucy Kemnitzer in r.a.sf.c

Please ignore Godzilla and its pseudonyms - do not feed the troll.




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

Date: Tue, 23 Jan 2001 15:10:39 -0800
From: Doral Vance Hackett <vanced@ohsu.edu>
Subject: formmail script not printing all fields
Message-Id: <3A6E0F6F.555CAFEC@ohsu.edu>

We recently updated our generic formmail script to Matt Wright's
FormMail.pl for processing web forms. Our old script was allowing
outside users to use our script for spamming purposes so we had to do
something quick.

One user noticed that this new script wasn't printing out all the
fields. After confirming that the "print_blank_fields" line was in
place, I couldn't see another reason for this. In fact, it's not just
blank fields that are being left out, but some that have data as well.
I'm new to Perl so I thought I'd ask here to see if anyone else had come
upon this problem before.

Doral Vance Hackett
vanced@ohsu.edu



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 129
**************************************


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