[21731] in Perl-Users-Digest
Perl-Users Digest, Issue: 3935 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 8 18:06:42 2002
Date: Tue, 8 Oct 2002 15:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 8 Oct 2002 Volume: 10 Number: 3935
Today's topics:
96-column punched-card data <Use-Author-Supplied-Address-Header@[127.1]>
Re: 96-column punched-card data <goldbb2@earthlink.net>
Re: 96-column punched-card data <Use-Author-Supplied-Address-Header@[127.1]>
Re: 96-column punched-card data <Use-Author-Supplied-Address-Header@[127.1]>
ack! what am i doing wrong with this array and array re (rebecca)
Re: ack! what am i doing wrong with this array and arra <penny1482@attbi.com>
Re: ack! what am i doing wrong with this array and arra <johannes.fuernkranz@t-online.de>
Re: ack! what am i doing wrong with this array and arra <goldbb2@earthlink.net>
Re: ack! what am i doing wrong with this array and arra (Tad McClellan)
Re: ack! what am i doing wrong with this array and arra <jeff@vpservices.com>
Re: array question <krahnj@acm.org>
Re: array question <goldbb2@earthlink.net>
effect of "use <version>" on forward-compatibility? <vhg@byu.edu>
Re: effect of "use <version>" on forward-compatibility? <goldbb2@earthlink.net>
Re: Flag processing <krahnj@acm.org>
Re: Fork question? <garry@ifr.zvolve.net>
Re: Fork question? <jhalpin@nortelnetworks.com_.nospam>
Re: Forking woes <goldbb2@earthlink.net>
Freeware/shareware perl IDE <N.Hirani@hgmp.mrc.ac.uk>
Re: I only need one row from mysql <bart.lateur@pandora.be>
Re: Intialising the COM port from Perl under W2K <brian_helterline@hp.com>
Re: needleman-wunsch alignment <boris.REMOVE.lenhard@cgb.ki.se>
Re: On Windows: ioctl.ph <bart.lateur@pandora.be>
Re: On Windows: ioctl.ph <goldbb2@earthlink.net>
Re: On Windows: ioctl.ph <rhedin@aquifer.geology.uiuc.edu>
Re: On Windows: ioctl.ph <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 8 Oct 2002 15:13:16 -0500 (CDT)
From: Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
Subject: 96-column punched-card data
Message-Id: <200210082013.g98KDGdT056715@cryptofortress.com>
Subject: 96-column punched-card data
Have you ever seen a 96-column card, the IBM 3700?
It's 3.25" x 2.625" and holds three rows of 32
characters for a total of 96.
If that isn't odd enough, when the card reader
transmits the data to memory, the data comes in-
in this order:
1 33 65 2 34 66 . . . 32 64 96
The job is to rearrange these 96 characters into
the correct order, 1 2 3 ... 94 95 96. On an
IBM mainframe, this takes one instruction,
TRANSLATE.
How cheaply, efficiently, cleverly can Perl
do this job? My first pass was to just
emulate the TRANSLATE instruction. Works OK,
but surely Perl can do this without even
taking a deep breath.
Anybody game to show what Perl can do?
------------------------------
Date: Tue, 08 Oct 2002 16:57:04 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: 96-column punched-card data
Message-Id: <3DA346A0.7AFC7240@earthlink.net>
Robert Brooks wrote:
>
> Subject: 96-column punched-card data
>
> Have you ever seen a 96-column card, the IBM 3700?
> It's 3.25" x 2.625" and holds three rows of 32
> characters for a total of 96.
>
> If that isn't odd enough, when the card reader
> transmits the data to memory, the data comes in-
> in this order:
>
> 1 33 65 2 34 66 . . . 32 64 96
>
> The job is to rearrange these 96 characters into
> the correct order, 1 2 3 ... 94 95 96. On an
> IBM mainframe, this takes one instruction,
> TRANSLATE.
>
> How cheaply, efficiently, cleverly can Perl
> do this job? My first pass was to just
> emulate the TRANSLATE instruction. Works OK,
> but surely Perl can do this without even
> taking a deep breath.
>
> Anybody game to show what Perl can do?
There may be more efficient ways to do it, but here's my go:
#!perl -ln
use integer;
use constant TRANSLATE =>
(map $_ * 3 + 0, 0..31),
(map $_ * 3 + 1, 0..31),
(map $_ * 3 + 2, 0..31);
print +(split //)[TRANSLATE];
__END__
[untested]
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 8 Oct 2002 16:56:28 -0500 (CDT)
From: Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
Subject: Re: 96-column punched-card data
Message-Id: <200210082156.g98LuSxN059267@cryptofortress.com>
In article <3DA346A0.7AFC7240@earthlink.net>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
> There may be more efficient ways to do it, but here's my go:
>
> #!perl -ln
> use integer;
> use constant TRANSLATE =>
> (map $_ * 3 + 0, 0..31),
> (map $_ * 3 + 1, 0..31),
> (map $_ * 3 + 2, 0..31);
> print +(split //)[TRANSLATE];
> __END__
> [untested]
>
Thanks for the code above. Unfortunately, I am too new
to Perl to understand what your code does. Might you
offer to add some comments that would help me to see
what it does?
Or, if you would prefer, just point me to section(s) of
The Camel Book and I will happily read/re-read until
it becomes clear. (I'm assuming that you are serious
and not just trying to have some fun with a Perl rookie.)
------------------------------
Date: Tue, 8 Oct 2002 16:57:29 -0500 (CDT)
From: Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
Subject: Re: 96-column punched-card data
Message-Id: <200210082157.g98LvTQ1059291@cryptofortress.com>
> There may be more efficient ways to do it, but here's my go:
>
> #!perl -ln
> use integer;
> use constant TRANSLATE =>
> (map $_ * 3 + 0, 0..31),
> (map $_ * 3 + 1, 0..31),
> (map $_ * 3 + 2, 0..31);
> print +(split //)[TRANSLATE];
> __END__
> [untested]
Sorry - I rushed an earlier reply.
Your code works! Now I just wish I understood how?!
After keying in your code to Perl script, I fed it
a file as if the card reader had transmitted the
data and it printed out EXACTLY the correct order
of data.
Wow! Wish I had some years of Perl experience built up
if only to see what the heck is going on here!
------------------------------
Date: 8 Oct 2002 11:10:50 -0700
From: rebecca@littlered.com (rebecca)
Subject: ack! what am i doing wrong with this array and array ref?
Message-Id: <f1a6a9f9.0210081010.4e7a0962@posting.google.com>
hi,
this may make some of you laugh, but i'm new to array refs and i don't
understand what is going on here. i return an array from a function:
my @stuff=locationSort($location);
i then pass it by ref into another function:
@list=getList($criteria,\@stuff,$count,\%matches);
my problem is that in getList, i can't read the reference right. i
followed what the documentation re: array refs says, but when i try to
read what i think is the first element of the array in getList, i see
the ENTIRE array (i.e. i see "0: elem1 elem2" etc. from the print
statement below):
sub getList{
my ($querycriteria,$arref,$count,$matches)=@_;
for (my $i=0; $i < @$aref; $i++) {
print "$i: $aref->[$i]<br>";
}
#other stuff taken out
}
if i fabricate a simple array before i call getList, the array ref
$aref->[$i] works in the function above. so my problem is in creating
the array from teh function locationSort, which generates the array
like this:
sub locationSort{
my ($location)=shift;
my @stuff;
# dbi stuff taken out
while (@row=$sth->fetchrow_array) {
push(@stuff,$row[0]);
}
return(@stuff);
}
okay. thanks for letting me vent my frustrations. i'm sure i've made
some egregious mistake with regard to arrays and array refs but maybe
one of you out there can enlighten me.
thanks!!!
------------------------------
Date: Tue, 08 Oct 2002 18:21:02 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Re: ack! what am i doing wrong with this array and array ref?
Message-Id: <imFo9.12658$YR.27790@rwcrnsc51.ops.asp.att.net>
I too am new at this, but I offer the following below and will follow this
thread.
"rebecca" <rebecca@littlered.com> wrote in message
news:f1a6a9f9.0210081010.4e7a0962@posting.google.com...
> hi,
>
> this may make some of you laugh, but i'm new to array refs and i don't
> understand what is going on here. i return an array from a function:
> my @stuff=locationSort($location);
> i then pass it by ref into another function:
> @list=getList($criteria,\@stuff,$count,\%matches);
>
> my problem is that in getList, i can't read the reference right. i
> followed what the documentation re: array refs says, but when i try to
> read what i think is the first element of the array in getList, i see
> the ENTIRE array (i.e. i see "0: elem1 elem2" etc. from the print
> statement below):
> sub getList{
> my ($querycriteria,$arref,$count,$matches)=@_;
1) make sure of what you've got by
ref $arref ? print "yes it is\n"; : print "no it aint\n";
> for (my $i=0; $i < @$aref; $i++) {
doesn't look right as count of items in 1st array, didn't deref (I think)
> print "$i: $aref->[$i]<br>";
2) print it with Data::Dumper, gives more info
use Data::Dumper
print Dumper $arref;
> }
> #other stuff taken out
> }
>
> if i fabricate a simple array before i call getList, the array ref
> $aref->[$i] works in the function above. so my problem is in creating
> the array from teh function locationSort, which generates the array
> like this:
> sub locationSort{
> my ($location)=shift;
> my @stuff;
> # dbi stuff taken out
> while (@row=$sth->fetchrow_array) {
> push(@stuff,$row[0]);
> }
>
> return(@stuff);
> }
>
> okay. thanks for letting me vent my frustrations. i'm sure i've made
> some egregious mistake with regard to arrays and array refs but maybe
> one of you out there can enlighten me.
>
> thanks!!!
------------------------------
Date: Tue, 08 Oct 2002 20:43:12 +0200
From: =?ISO-8859-1?Q?Johannes_F=FCrnkranz?= <johannes.fuernkranz@t-online.de>
Subject: Re: ack! what am i doing wrong with this array and array ref?
Message-Id: <anv93f$db3$06$1@news.t-online.com>
rebecca wrote:
> hi,
>
> this may make some of you laugh, but i'm new to array refs and i don't
> understand what is going on here. i return an array from a function:
> my @stuff=locationSort($location);
> i then pass it by ref into another function:
> @list=getList($criteria,\@stuff,$count,\%matches);
>
> my problem is that in getList, i can't read the reference right. i
> followed what the documentation re: array refs says, but when i try to
> read what i think is the first element of the array in getList, i see
> the ENTIRE array (i.e. i see "0: elem1 elem2" etc. from the print
> statement below):
> sub getList{
> my ($querycriteria,$arref,$count,$matches)=@_;
Did you cut and paste this code? You use $arref here and $aref below...
In any case,
use strict;
use warnings;
then such things won't happen.
> for (my $i=0; $i < @$aref; $i++) {
> print "$i: $aref->[$i]<br>";
> }
> #other stuff taken out
> }
>
> if i fabricate a simple array before i call getList, the array ref
> $aref->[$i] works in the function above. so my problem is in creating
Beats me. The code looks alright to me, but I haven't tried it.
Maybe you should *really* take everything out and try the code as you
posted it.
> the array from teh function locationSort, which generates the array
> like this:
> sub locationSort{
> my ($location)=shift;
Why are you putting $location in list context? I don't think it makes
a difference, but the normal way of writing this is
my $location = shift;
Only use parens when you assign more than one variable (unless you know
what you're doing).
> my @stuff;
> # dbi stuff taken out
> while (@row=$sth->fetchrow_array) {
> push(@stuff,$row[0]);
> }
>
> return(@stuff);
> }
Juffi
------------------------------
Date: Tue, 08 Oct 2002 15:07:30 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ack! what am i doing wrong with this array and array ref?
Message-Id: <3DA32CF2.F0596EC9@earthlink.net>
rebecca wrote:
>
> hi,
>
> this may make some of you laugh, but i'm new to array refs and i don't
> understand what is going on here.
That's prefectly ok.
> i return an array from a function:
You mean, you return a *list* from a function.
> my @stuff=locationSort($location);
And then you store that list in an array.
> i then pass it by ref into another function:
> @list=getList($criteria,\@stuff,$count,\%matches);
And then you pass a ref to the array that you stored the list in, to
another function.
>
> my problem is that in getList, i can't read the reference right. i
> followed what the documentation re: array refs says, but when i try to
> read what i think is the first element of the array in getList, i see
> the ENTIRE array (i.e. i see "0: elem1 elem2" etc. from the print
> statement below):
I doubt that that really happened.
I'd be willing to bet that your *original* print statement was something
like:
print "$i: @$aref ->[$i]<br>";
or something equally wierd.
> sub getList{
> my ($querycriteria,$arref,$count,$matches)=@_;
> for (my $i=0; $i < @$aref; $i++) {
> print "$i: $aref->[$i]<br>";
> }
> #other stuff taken out
> }
You should indent your code better, and it will be easier to see.
Also, you should copy&paste, not retype.
Try writing the code like this:
sub getList {
my ($q_criteria, $aref, $count, $match_hash) = @_;
for my $i ( 0 .. $#$aref ) {
print "$i: $$aref[$i]<br>\n";
}
# other stuff here.
}
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 8 Oct 2002 14:13:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ack! what am i doing wrong with this array and array ref?
Message-Id: <slrnaq6bjn.3gm.tadmc@magna.augustmail.com>
rebecca <rebecca@littlered.com> wrote:
>
> this may make some of you laugh, but i'm new to array refs and i don't
> understand what is going on here. i return an array from a function:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is _not possible_ to return an array from a function in Perl.
> my @stuff=locationSort($location);
locationSort() returns a _list_ (which your code then copies
into an array), not an array.
See the Perl FAQ:
"What is the difference between a list and an array?"
> i then pass it by ref into another function:
> @list=getList($criteria,\@stuff,$count,\%matches);
That part looks OK.
> sub getList{
> my ($querycriteria,$arref,$count,$matches)=@_;
^^^^^
^^^^^
> for (my $i=0; $i < @$aref; $i++) {
^^^^
^^^^
Is that your real code? Do you have warnings enabled?
If so, then where does $aref get its value from?
If not, then why not show us your real code?
Please do not attempt to retype code, use copy/paste.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 08 Oct 2002 12:19:53 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: ack! what am i doing wrong with this array and array ref?
Message-Id: <3DA32FD9.9070408@vpservices.com>
rebecca wrote:
>my ($querycriteria,$arref,$count,$matches)=@_;
> for (my $i=0; $i < @$aref; $i++) {
> print "$i: $aref->[$i]<br>";
> }
This is the only thing I can spot that is wrong. You use $arref (with
two r's) when you get the params and $aref (with one r) below it. If
this is a typo in the posting but not the code, please cut and paste
instead. If its a typo in the code, please set warnings on to catch
this kind of thing.
Otherwise, you seem to be using arrays and arrayrefs fine as far as I
could see.
One other minor thing, you have:
> # dbi stuff taken out
> while (@row=$sth->fetchrow_array) {
> push(@stuff,$row[0]);
> }
If all you're doing is putting the values for one column into an array,
you don't need a statement handle or a fetch loop, just do this:
my $stuff = $dbh->selectcol_arrayref("SELECT myCol FROM myTable");
Notice that that's a $dbh, not a $sth and that $stuff will be an arrayref.
--
Jeff
------------------------------
Date: Tue, 08 Oct 2002 19:08:22 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: array question
Message-Id: <3DA32D12.398D12B0@acm.org>
Tina Mueller wrote:
>
> John W. Krahn <krahnj@acm.org> wrote:
> >>
> >> delete $fruits[$index];
>
> > This is the same as $fruits[$index] = undef;
>
> actually, it's different:
> $ perl -wle'
> @a = qw(a b c);
> $a[0] = undef;
> print exists $a[0] ? 1 : 0;
> delete $a[0];
> print exists $a[0] ? 1 : 0;'
> 1
> 0
$ perl -wle'
@a = qw(a b c);
print @a . " @a";
delete $a[0];
print @a . " @a";
$a[0] = undef;
print @a . " @a";
'
3 a b c
Use of uninitialized value in join at -e line 5.
3 b c
Use of uninitialized value in join at -e line 7.
3 b c
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 08 Oct 2002 15:54:49 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: array question
Message-Id: <3DA33809.3C30FC35@earthlink.net>
John W. Krahn wrote:
[snip]
> $ perl -wle'
> @a = qw(a b c);
> print @a . " @a";
> delete $a[0];
> print @a . " @a";
> $a[0] = undef;
> print @a . " @a";
> '
> 3 a b c
> Use of uninitialized value in join at -e line 5.
> 3 b c
> Use of uninitialized value in join at -e line 7.
> 3 b c
perl -wl
@a = qw(a b c);
print @a . " @a";
delete $a[2];
print @a . " @a";
$a[2] = undef;
print @a . " @a";
__END__
3 a b c
2 a b
Use of uninitialized value in join or string at - line 6.
3 a b
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 08 Oct 2002 15:00:18 -0600
From: Vaughn Gardner <vhg@byu.edu>
Subject: effect of "use <version>" on forward-compatibility?
Message-Id: <3DA34762.1080706@byu.edu>
I'm trying to convince a very conservative operations center to upgrade
the version of Perl available on our boxes. I'd like to guarantee that
old code would work on the newer version (we have versions as old as
4.0.1.8 with code running against them).
Does the "use <version>" pragma help with forward compatibility in any
way? I know that it will make the code fail if run against an earlier
version...
Vaughn
------------------------------
Date: Tue, 08 Oct 2002 17:56:10 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: effect of "use <version>" on forward-compatibility?
Message-Id: <3DA3547A.FEEB8D3C@earthlink.net>
Vaughn Gardner wrote:
>
> I'm trying to convince a very conservative operations center to
> upgrade the version of Perl available on our boxes.
Good for you!
> I'd like to guarantee that old code would work on the newer version
> (we have versions as old as 4.0.1.8 with code running against them).
Err, why? You do know that you can have many different versions of perl
installed on a system, right?
Assuming a unix system, then 99.9% of your perl scripts start off with:
#!/usr/bin/perl
Or some other hardcoded path.
The other 0.1% have stuff like
#!/usr/bin/env name=val perl
or don't have any #! line and are started by some other script as
something like "perl foo.pl".
Just have your newer version of perl installed somewhere else. The
scripts with a normal #! line will continue to work, and the ones which
ask the 'env' program to find them, or else are started with "perl x.pl"
might possibly break, but they should be small enough in number to find
them and fix them.
For new scripts, using the newer versions of perl, you just do:
#!/path/to/newer/perl
which may be something like:
#!/usr/bin/perl5.6.1
or
#!/usr/bin/perl5.8.0
> Does the "use <version>" pragma help with forward compatibility in any
> way?
Not that I know of.
> I know that it will make the code fail if run against an earlier
> version...
Yes -- this might seem like a useless feature, but consider:
Suppose your program will still run if put onto an older perl, but
functions incorrectly, without it producing any warning or error
messages ... the end user wouldn't know what's wrong. An early abort
will prevent that.
What if it makes use of new language features and running it on an older
perl produces strange, ugly error messages ... this can confuse the end
user. Printing out that you don't have a new enough perl, and aborting,
will avoid confusion.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 08 Oct 2002 19:44:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Flag processing
Message-Id: <3DA33598.ECF6FAE2@acm.org>
"Teh (tî'pô)" wrote:
>
> I'm maintaining some old code loops over lots of stuff looking for
> flags. For example:
> if($flag =~ /^-dir:/ ) {
> $flag = $';
>
> [snip]
>
> I think I remember seeing somewhere that $' is not efficient and
> should be avoided so I changed some of these to:
> if($flag =~ /^-dir:(.*)/o ) { # added the o modifier too
> $flag = $1;
>
> [snip]
>
> I then thought that it might be simpler to uses s//:
> if( $flag =~ s/^-dir//o ) {
>
> [snip]
>
> What's the preferred way to do stuff like this?
You probably want to use $flag =~ /^-dir:(.*)/ and the /o modifier isn't
going to help as there are no variables in the regular expression. Of
course, it depends on how the data is stored. :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 08 Oct 2002 18:11:23 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: Fork question?
Message-Id: <slrnaq67o3.rb8.garry@zfw.zvolve.net>
On 08 Oct 2002 10:58:45 -0500, Joe Halpin
<jhalpin@nortelnetworks.com_.nospam> wrote:
> paulthomson@hotmail.com (paul) writes:
>
>> I have an application that sends messages(stored in mySQL) to a
>> server using IO::Socket. There might be times when I need to speed
>> up the process. For example, if there 1000 messages - rather than
>> sending them one at a time I would like the application to 'split'
>> 10 times and each child to send 100 each and (in theory) speed
>> things up greatly.
>>
>> I have taken a quick look at fork and before I go mad and build the
>> application I wondered what alternatives I have. Am I even barking
>> up the wrong tree with fork?
>
> You probably will wind up with interleaved messages doing it that
> way. Each child process is going to be writing into the same TCP send
> queue. Child process scheduling, when the send queue fills up and who
> gets to it first after that, aren't things you can control from an
> application.
>
> If you had a different connection for each child, and the receiving
> application could put them in order, that might work.
>
> I'd consider compression instead though personally. The zlib library
> works very nicely, and has a perl module to access it with on
> CPAN. There are a few other modules that provide
> compression/decompression as well there.
Aside from Benjamin's admonition to *not* optimize until there's a
problem, you will probably find that compression will _slow_
performance on a local network.
Benchmark it and see. The last time I did, I _removed_ compression to
improve throughput.
--
Garry Williams
------------------------------
Date: 08 Oct 2002 16:18:37 -0500
From: Joe Halpin <jhalpin@nortelnetworks.com_.nospam>
Subject: Re: Fork question?
Message-Id: <yxs7n0pomxxu.fsf@zrc2h0n4.us.nortel.com>
Garry Williams <garry@ifr.zvolve.net> writes:
> On 08 Oct 2002 10:58:45 -0500, Joe Halpin
> <jhalpin@nortelnetworks.com_.nospam> wrote:
> > paulthomson@hotmail.com (paul) writes:
> > I'd consider compression instead though personally. The zlib
> > library works very nicely, and has a perl module to access it with
> > on CPAN. There are a few other modules that provide
> > compression/decompression as well there.
>
> Aside from Benjamin's admonition to *not* optimize until there's a
> problem, you will probably find that compression will _slow_
> performance on a local network.
The OP didn't say it was on a local network, and all I said was to
consider it.
> Benchmark it and see. The last time I did, I _removed_ compression to
> improve throughput.
The last time I tried it, it improved throughput.
The kind of data being sent, the number of routers it's being sent
through (or whether it's being sent through routers), the zlib
compression level being used, etc, etc, etc, all come into play.
But I take your point. Benchmark it and see.
Joe
------------------------------
Date: Tue, 08 Oct 2002 16:03:11 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Forking woes
Message-Id: <3DA339FF.81A2B287@earthlink.net>
Mark Morgan wrote:
>
> Hi all,
>
> Hoping someone can offer some insight here. :) I have a perl
> script I've written whos job it is to do some work, fork a child
> (daemon) and then exit.
> This seems to work great in most circumstances. I had some initial
> issues with closing out file descriptors which gave me woes early on,
> but I've worked those out now. I've now tested the script using perl,
> C-system calls and C-exec calls, and all work well and return
> properly.
>
> So here's the issue. We run a third-party solution also written in
> C, which also makes system calls. When setting up this program to
> call my perl script, however, it hangs and waits for the child process
> to return.
Is it waiting for your perl process to return, or is it waiting for the
pipe(s) it made to/from your perl process to close?
> Obviously since the child is a daemon, it never returns, and thus the
> call never returns in the third party software. Obviously bad
> behaviour.
If the 3rdparty thing is waiting for your *process*, eg, with waitpid,
then it shouldn't matter if the daemon never exits.
It will only wait forever if it's waiting for something it gave you (a
filehandle, perhaps) to be destroyed.
> Obviously, I don't have the vendor's code to look at to see exactly
> how they're calling exec/wait. Has anyone ever seen similar
> behaviour, or does someone more knowledgable in the ways of exec/wait
> have some insight to offer?
With many web servers, your process is assumed to be complete when the
stdout and stderr pipes it gave you get closed, *not* when your process
exits. If you fork a child and exit, and that child inherits from you
stdout and stderr, and doesn't close them, the httpd will wait for that
child to finish.
> I'd like to be able to reproduce the error myself, but my meagre
> attempts at using a simple exec/wait always work fine. I'm thinking
> the vendor must be specifying some sort of flag which is telling
> wait() to wait for all grandchildren to return.. any ideas?
I've never heard such a thing.
The fact that the daemon is your grandchild means nothing to wait().
It does mean that the daemon will be in your process group, but AFAIK,
the only consequence of the a process being in a particular process
group is that when a signal is sent to the group, all members of the
group recieve the signal.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 08 Oct 2002 21:13:37 +0100
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: Freeware/shareware perl IDE
Message-Id: <3DA33C71.FE650EC3@hgmp.mrc.ac.uk>
Hi,
I'm looking for a nice freeware/shareware perl IDE that runs on a Sun
Solaris platform.
Does such a thing exist?
if so does any body have any recommendations, please.
I am aware of one or two nice offerings for the windows platform, but I
am really after something
equivalent for the unix (Sun flavour) platform.
Please CC your response to me if possible.
TIA.
Naran
------------------------------
Date: Tue, 08 Oct 2002 19:26:23 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: I only need one row from mysql
Message-Id: <b8c6qus2k1jvgqj8g4tnp2lmnvofob5qhi@4ax.com>
bernie wrote:
> With the way I have my database and select statement setup I know I
>will only how one row returned, how would I get it without doing a loop?
Get it as you would in a loop, but don't use a loop. For example, use
"if" instead of "while".
Don't forget to do
$sth->finish;
after you get your one row. Some database engines will complain,
otherwise.
--
Bart.
------------------------------
Date: Tue, 8 Oct 2002 11:40:12 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: Intialising the COM port from Perl under W2K
Message-Id: <anv8sr$mto$1@hpcvsgen.cv.hp.com>
"Graeme" <invalid@pinnock.com> wrote in message
news:53Fo9.672$B66.81858@newsfep2-gui...
>
> ActivePerl 5.6.1.628
> W2000 SP3
>
> I'm trying to capture caller ID information from my modem to keep a
> log of incoming calls but I'm having problem talking to the modem on
> either of my COMM ports. When I first run the following code after a
> boot it doesn't error it just doesn't get anything from the modem. If
> I go into TERMINAL and access the same COMM port I get normal
> responses to AT etc. After going into terminal the perl code runs fine
> until the next boot. I'm trying to initialise the COMM port using MODE
> from within the code but it doesn't seem to work?
>
> If anyone has any ideas, I'd appreciate any help.
Try using the Win32 SerialPort module.
------------------------------
Date: Tue, 08 Oct 2002 19:57:26 GMT
From: Boris <boris.REMOVE.lenhard@cgb.ki.se>
Subject: Re: needleman-wunsch alignment
Message-Id: <GMGo9.3603$V6.402370@news01.chello.se>
Try
http://world.std.com/~swmcd/steven/perl/pm/xs/nw/Perl/Align-NW-1.00.tar.gz
Stanley Lee wrote:
> hi im new to perl. i am trying to implement a needlman-wunsch
> alignment algorithm. where the script takes 2 sequences, constructs a
> scoring matrix, iterates through it to determine prime alignment and
> then prints it out. first step constructs a 1-0 matrix with 1 assigned
> to wherever the sequences match. second step iterates through matrix
> backwards to add up the max from each previous adjacent row and
> column. now i must iterate thru the matrix again to grab the index of
> the max of each row i encounter as i go from top left corner to lower
> right hand corner. this i have trouble with. given a matrix, does
> anyone have any code to grab the indices and print out the
> corresponding alignment string of the sequences? see here for details
> : http://helix.biology.mcmaster.ca/721/align.html
>
> thanks for the help! stanley.
------------------------------
Date: Tue, 08 Oct 2002 19:50:23 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: On Windows: ioctl.ph
Message-Id: <lmd6qu0gbqgmet3raij42e1m09jpuoc4td@4ax.com>
Rick Hedin wrote:
>Hi. Has someone made an ioctl.ph for Windows? Is it available?
>
>I need F_GETFL defined, and so forth.
It looks to me that you can get it out of Fcntl (Fcntl.pm), among the
default exported constants.
--
Bart.
------------------------------
Date: Tue, 08 Oct 2002 16:46:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: On Windows: ioctl.ph
Message-Id: <3DA3441B.E28527A1@earthlink.net>
Rick Hedin wrote:
>
> Hi. Has someone made an ioctl.ph for Windows? Is it available?
>
> I need F_GETFL defined, and so forth.
For what? Setting nonblocking? IO::Handle defines a ->blocking method,
and you can pass it a 0 to turn blocking off.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Tue, 8 Oct 2002 16:30:24 -0500
From: "Rick Hedin" <rhedin@aquifer.geology.uiuc.edu>
Subject: Re: On Windows: ioctl.ph
Message-Id: <A4Io9.34628$m7.321214@vixen.cso.uiuc.edu>
That's right. I'm trying to set the channel not to block if no information
is available.
Thanks for the clues. I'll go try to apply them.
Regards,
Rick
------------------------------
Date: Tue, 08 Oct 2002 17:59:56 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: On Windows: ioctl.ph
Message-Id: <3DA3555C.7F5A89E3@earthlink.net>
Rick Hedin wrote:
>
> That's right. I'm trying to set the channel not to block if no
> information is available.
I didn't mention it, but nonblocking io isn't really the best way to
avoid blocking.
It's better to use select(), so you can find out which ones of a set of
filehandles can be read from without blocking... and if none are ready,
you can go and do some other task in the meantime.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
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 3935
***************************************