[25382] in Perl-Users-Digest
Perl-Users Digest, Issue: 7627 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 10 18:05:49 2005
Date: Mon, 10 Jan 2005 15: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)
Perl-Users Digest Mon, 10 Jan 2005 Volume: 10 Number: 7627
Today's topics:
Re: a new Perl/Python a day <rff_rff@remove-yahoo.it>
Re: assembling a signed integer from bytes <jgibson@mail.arc.nasa.gov>
Re: complex numbers <a.newmane.remove@eastcoastcz.com>
Re: copying values from a hash into CGI.pm via tied has <jgibson@mail.arc.nasa.gov>
Re: data structure <sjs@sonic.net>
Re: Differences in UTF-8 html form inputs <flavell@ph.gla.ac.uk>
Re: Differences in UTF-8 html form inputs <realbot@goooglemail.com>
eliminating empty elements of a list <hendrik_maryns@despammed.com>
Re: eliminating empty elements of a list <bik.mido@tiscalinet.it>
Re: eliminating empty elements of a list <jgibson@mail.arc.nasa.gov>
Re: eliminating empty elements of a list (Anno Siegel)
Re: eliminating empty elements of a list <hendrik_maryns@despammed.com>
Re: FAQ 4.30: How do I capitalize all the words on one <news@chaos-net.de>
Re: HELP needed for a small script <tadmc@augustmail.com>
Re: Interactive shell from system()? <mritty@gmail.com>
Re: IPC looking for simple/best way to communicate whansen_at_corporate-image_dot_com@us.com
Re: IPC looking for simple/best way to communicate whansen_at_corporate-image_dot_com@us.com
Re: IPC looking for simple/best way to communicate whansen_at_corporate-image_dot_com@us.com
Re: IPC looking for simple/best way to communicate <jgibson@mail.arc.nasa.gov>
Re: Is zero even or odd? <a.newmane.remove@eastcoastcz.com>
Re: passing $cgi object in hash. <tadmc@augustmail.com>
Re: perl tutorial <tadmc@augustmail.com>
Re: specifying use strict <carlton_gregory@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Jan 2005 18:38:14 GMT
From: gabriele renzi <rff_rff@remove-yahoo.it>
Subject: Re: a new Perl/Python a day
Message-Id: <qYzEd.24632$H%6.974230@twister1.libero.it>
Bob Smith ha scritto:
> Scott Bryce wrote:
>
>> Xah Lee wrote:
>>
>>> frustrated constantly by its inanities and incompetences.)
>>
>>
>> I don't see what this has to do with Perl.
>
>
> You're joking, right?
please consider that the message you all are asking are crossposted to
comp.lang.perl.misc and comp.lang.python, avoid the crossgroup flames :)
------------------------------
Date: Mon, 10 Jan 2005 10:08:05 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: assembling a signed integer from bytes
Message-Id: <100120051008056495%jgibson@mail.arc.nasa.gov>
In article <slrncu0qqs.l1l.abigail@alexandra.abigail.nl>, Abigail
<abigail@abigail.nl> wrote:
> Steve (ineverlookatthis@yahoo.com) wrote on MMMMCXLVIII September
> MCMXCIII in <URL:news:f0d57f86.0501081254.222b359c@posting.google.com>:
> ** Hi all
> **
> ** I am reading data from a serial device with perl, capturing each group
> ** as an array of numbers generated from the ord of each character. I
> ** don't know exactly how it is formatted, but having looked at the way
> ** the values vary and knowing the type of data being transmitted, it
> ** seems likely that I have several signed numbers each compsed of two of
> ** my bytes.
> **
> ** How do I assemble two variables, each carrying a number 0-255 into a
> ** single, two-byte signed number?
>
>
> You'd use pack and unpack.
For my own edification, I came up with this:
#!/usr/local/bin/perl
#
use strict;
use warnings;
my @bytes = qw/ 128 5 /;
my $binary = pack('CC',@bytes);
my $short = unpack('s',$binary);
printf "short = %d (hex %x)\n", $short, $short;
__OUTPUT__
short = -32763 (hex ffff8005)
Note that C is the pack/unpack template character for unsigned char
value and s is for signed short.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Mon, 10 Jan 2005 09:51:28 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: complex numbers
Message-Id: <34ftl8F48t3b9U1@individual.net>
J|rgen Exner wrote:
> xah@xahlee.org wrote:
>> #python supports complex numbers.
> [...]
>
> So?
>
>> # Perl doesn't support complex numbers. But there are packages that
>> supports it.
>
> The Math::Complex module is part of the standard installation
> already, no need for any "packages" (whatever that might be).
'package' is a keyword, you should know this :-) Thats an important part
of most modules.
Actually it seems a lot of people use 'module' and 'package'
interchangably, both refering to libraries, if you will, the one can
include in a script, or another package.
------------------------------
Date: Mon, 10 Jan 2005 10:44:41 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: copying values from a hash into CGI.pm via tied hash reference
Message-Id: <100120051044410698%jgibson@mail.arc.nasa.gov>
In article <1105363359.694486.301320@c13g2000cwb.googlegroups.com>,
Tomi Häsä <tomi.hasa@gmail.com> wrote:
> ioneabu@yahoo.com wrote:
> >
> > Regarding my poor posting practices recently, specifically
> > improper quoting, this is due to Google's new beta version of
> > groups.google.com.
> > [...]
> >
> > I hope that Google fixes this, I don't know exactly who to
> > complain to.
>
> If you want to report problems with Google Groups Beta, you can use
> this feedback page:
>
> http://groups-beta.google.com/support/bin/request.py
...
> This message contains a list of some the bugs and problems that have
> been reported so far:
>
> http://groups-beta.google.com/group/google-labs-groups2/msg/b54c12517c75eb24
I checked that page and, while some formatting problems were reported,
there was none specifically on removing indenting from source code. So
I submitted one.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Mon, 10 Jan 2005 16:04:30 GMT
From: Steven_Smith <sjs@sonic.net>
Subject: Re: data structure
Message-Id: <iIxEd.1074$m31.13036@typhoon.sonic.net>
mxa@yahoo.com wrote:
> Hi,
> I need to set up a data structure that is very similar to two level
> unix directory.
> my ( @files, %dir )
> @files=('file1','file2','file3');
> $dir{'mydir'} = ( @files)
> $dir{'root'} = ( $dir{'mydir'})
>
I use a recursive hash that looks like
my %dirs = (
dirs => {},
files => [],
);
Each dirs reference will then point at another dirs
hash, so to go a bit deeper:
%dirs = (
dirs => { dirs => { dirs => { ...},
files => [...],
},
files => [ ... ],
},
files => [ ... ],
);
Things get a bit more complicated when you start throwing
in links, but for most of what I do, I ignore them.
Steve S.
Steve S.
------------------------------
Date: Mon, 10 Jan 2005 21:04:14 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Differences in UTF-8 html form inputs
Message-Id: <Pine.LNX.4.61.0501102049480.15424@ppepc56.ph.gla.ac.uk>
On Sat, 8 Jan 2005, Realbot wrote:
> I'm having some problems with a web application of mine.
Forms submission including characters outside of us-ascii is
non-trivial, and isn't in itself a Perl problem.
OT: commentary of mine at
http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html
Until one can get that part sorted out to one's satisfaction, any
fiddling around that one might do in one's Perl script would be a bit
pointless, IMHO. And discussion of the web part would be more at home
on comp.infosystems.www.authoring.cgi (beware the automoderation bot).
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
If we assume that the page itself is really coded in utf-8 (note that
in the event of a dispute, the server's actual HTTP Content-type
header wins over anything that you might secrete in a meta
http-equiv), then you can expect current browsers to submit
utf-8-encoded form data. But not-quite-so-new browsers - even some
which support utf-8 display - get utf-8 forms submission sadly wrong.
> <form name="formutfget" method="GET">
In -theory- the method GET supports nothing better than the us-ascii
character coding. But see my commentary for further discussion.
> The strange thing is that running this form under these environments
[...]
> So, it seems that in the former I get escaped unicode character and
> in the latter UTF-8 ones.
It looks as if somebody is trying to ape the misbegotten behaviour of
MSIE.
In a practical sense there isn't one right answer - there are several
compromises, depending on which browsers support what. But none of
the details here are features of the Perl programming language,
AFAICS.
good luck
------------------------------
Date: Mon, 10 Jan 2005 23:15:22 +0100
From: Realbot <realbot@goooglemail.com>
Subject: Re: Differences in UTF-8 html form inputs
Message-Id: <41e2fe66$0$10913$5fc30a8@news.tiscali.it>
Alan J. Flavell wrote:
> On Sat, 8 Jan 2005, Realbot wrote:
>
> Forms submission including characters outside of us-ascii is
> non-trivial, and isn't in itself a Perl problem.
>
> OT: commentary of mine at
> http://ppewww.ph.gla.ac.uk/~flavell/charset/form-i18n.html
I read it avidly before posting, very well written.
> Until one can get that part sorted out to one's satisfaction, any
> fiddling around that one might do in one's Perl script would be a bit
> pointless, IMHO. And discussion of the web part would be more at home
> on comp.infosystems.www.authoring.cgi (beware the automoderation bot).
>
>
>> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>
>
> If we assume that the page itself is really coded in utf-8 (note that
> in the event of a dispute, the server's actual HTTP Content-type
> header wins over anything that you might secrete in a meta
> http-equiv), then you can expect current browsers to submit
> utf-8-encoded form data.
I found out that this was the exact problem. Apache installed on all Debian versions is configured with
AddDefaultCharset on
which completely ignores the encoding given in META tag and uses always the default encoding.
In Apache installation under OpenBSD the parameter was not present and so it was correct.
When I removed that nasty parameter everything worked on Debian too...
> In a practical sense there isn't one right answer - there are several
> compromises, depending on which browsers support what. But none of
> the details here are features of the Perl programming language,
> AFAICS.
Now I know! :-)
Thanks a lot.
------------------------------
Date: Mon, 10 Jan 2005 22:11:59 +0100
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: eliminating empty elements of a list
Message-Id: <u72dneRQ6bk9cn_cRVnytA@scarlet.biz>
Hi,
I was wondering wether there is an easy way to eliminate all undefined
or empty elements of a list, except from skipping through it with a
foreach loop and rebuilding it. So, if I had a list like this:
(5,"jan","",$whatever,undef,undef,"someotherstring")
The result should be
(5,"jan",$whatever,"someotherstring")
Notice that I want the empty string to be removed too.
If this is a FAQ, I apologise, and would be very happy with a link.
Thanks, Hendrik
------------------------------
Date: Mon, 10 Jan 2005 22:19:24 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: eliminating empty elements of a list
Message-Id: <s8s5u0d675tik2gs5db5f03b7t6ru7c94q@4ax.com>
On Mon, 10 Jan 2005 22:11:59 +0100, Hendrik Maryns
<hendrik_maryns@despammed.com> wrote:
>I was wondering wether there is an easy way to eliminate all undefined
>or empty elements of a list, except from skipping through it with a
>foreach loop and rebuilding it. So, if I had a list like this:
>
>(5,"jan","",$whatever,undef,undef,"someotherstring")
>
>The result should be
>
>(5,"jan",$whatever,"someotherstring")
my @newlist = grep $_, @oldlist;
# perldoc -f grep
HTH,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 10 Jan 2005 13:46:23 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: eliminating empty elements of a list
Message-Id: <100120051346234829%jgibson@mail.arc.nasa.gov>
In article <s8s5u0d675tik2gs5db5f03b7t6ru7c94q@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> On Mon, 10 Jan 2005 22:11:59 +0100, Hendrik Maryns
> <hendrik_maryns@despammed.com> wrote:
>
> >I was wondering wether there is an easy way to eliminate all undefined
> >or empty elements of a list, except from skipping through it with a
> >foreach loop and rebuilding it. So, if I had a list like this:
> >
> >(5,"jan","",$whatever,undef,undef,"someotherstring")
> >
> >The result should be
> >
> >(5,"jan",$whatever,"someotherstring")
>
> my @newlist = grep $_, @oldlist;
Keep in mind that this will also eliminate any element with a value 0.
If that is not wanted, change to:
my @newlist = grep { defined && ($_ ne '') } @oldlist;
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: 10 Jan 2005 22:08:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: eliminating empty elements of a list
Message-Id: <cruudn$ojv$1@mamenchi.zrz.TU-Berlin.DE>
Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in comp.lang.perl.misc:
[...]
> Keep in mind that this will also eliminate any element with a value 0.
> If that is not wanted, change to:
>
> my @newlist = grep { defined && ($_ ne '') } @oldlist;
Equivalent, but more common:
my @newlist = grep { defined && length } @oldlist;
Anno
------------------------------
Date: Mon, 10 Jan 2005 23:20:56 +0100
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: Re: eliminating empty elements of a list
Message-Id: <JeGdnZME291WYn_cRVnyvg@scarlet.biz>
Anno Siegel schreef:
> Jim Gibson <jgibson@mail.arc.nasa.gov> wrote in comp.lang.perl.misc:
>
> [...]
>
>
>>Keep in mind that this will also eliminate any element with a value 0.
>>If that is not wanted, change to:
>>
>> my @newlist = grep { defined && ($_ ne '') } @oldlist;
>
>
> Equivalent, but more common:
>
> my @newlist = grep { defined && length } @oldlist;
>
> Anno
Thanks all!
Actually, I solved my problem in a totally different way, making what I
asked here unnecessary, but thanks anyway. I guess, I'll have to read
some more tutorials, as I didn't know you could use grep _inside_ Perl.
You are sure this works on Windows right?
Hendrik
PS: What is the difference between c.l.p.misc, c.l.p, c.l.p.moderated
and c.l.p.tk?
------------------------------
Date: 10 Jan 2005 17:25:31 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: FAQ 4.30: How do I capitalize all the words on one line?
Message-Id: <slrncu5ekb.5n4.news@maki.homeunix.net>
Michele Dondi wrote :
> On 10 Jan 2005 03:50:34 GMT, Martin Kissner <news@chaos-net.de> wrote:
>
>>When $LANG is set _in_ the script, it seems not to get use.
>>How can I set $LANG in the script?
>
> Wild guess: isn't it that it must be set suitably _before_ locale.pm
> is loaded? If so, then
>
> BEGIN { $ENV{LANG}='de_DE.ISO8859-1' }
> use locale;
>
> _may_ (untested!) do the job.
I had this idea, too and tried last night before I posted my question.
Then I followed sherms advice to again check the documentation.
| [...] *at least one of the following must be true:*
|
| The locale-determining environment variables (see "ENVIRONMENT")
| must be correctly set up at the time the application is started,
| [...]
| The application must set its own locale using the method described
| in "The setlocale function".
| [...]
Thank you, anyways.
--
Epur Si Muove (Gallileo Gallilei)
------------------------------
Date: Mon, 10 Jan 2005 15:31:31 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: HELP needed for a small script
Message-Id: <slrncu5t1j.8bi.tadmc@magna.augustmail.com>
Muller <Some.One@hotmail.com> wrote:
> If you are dying then you should choke in "perl", otherwise people here
> will not help you
Thank you for identifying yourself.
I will make use of the information you have provided here!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 10 Jan 2005 16:25:49 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Interactive shell from system()?
Message-Id: <h0yEd.3787$C.2551@trnddc05>
<bh_ent@hotmail.com> wrote in message
news:1105371577.284149.230290@c13g2000cwb.googlegroups.com...
>
> After reading the documentation for "system()" I understand perl
> launches the arguments via "sh -c" or whatever my system equivalent
is.
>
> I've written a series of ksh scripts I'd like to launch from my perl
> script, but the ksh scripts are interactive (ie, prompts the user, and
> reads their input), however, this obviously doesn't work via system()
> from within my perl script.
> Any suggestions how I might accomplish this?
system() is not suitable to your task.
Check out Expect or Expect::Simple, both available from
http://search.cpan.org
Paul Lalli
------------------------------
Date: Mon, 10 Jan 2005 20:39:18 GMT
From: whansen_at_corporate-image_dot_com@us.com
Subject: Re: IPC looking for simple/best way to communicate
Message-Id: <41e2e4f2.2112224@news.sonic.net>
Intersperesed below:
On 07 Jan 2005 20:24:52 GMT, xhoster@gmail.com wrote:
>whansen_at_corporate-image_dot_com@us.com wrote:
>> I'm trying to find the best way to do something. I've got 50 processes
>> (may have 200 soon) that need to broadcast simple messages to each of
>> them. I tried doing this with sockets, but although I was able to get
>> them to read a socket without halting succesfully I found that when
>> one process reads a socket it removes the message from the socket and
>> the other processes don't see it.
>
>You need a separate socket to each process, and send the message to each of
>those sockets. I'd probably have one house-keeper process which collects
>messages from all 50 processes and redistributes them to all 50 processes,
>although I don't know that that is necessary.
If I go this way I probably should set up a server on a socket and
have it maintain the list centrally, but I'm a little unsure of the
speed. The 50 processes can iterate as fast as 3 times a second or 150
times a second for all of them. A central server process is going to
need to be able to keep up with this rate.
>> My current solution works using
>> IPC::Shareable, but is slow and hogs memory as well as the CPU.
>> Shareable lets you set a variablle that multiple programs can read and
>> write to. In my case they read and write to the list that they all run
>> off.
>
>You probably shouldn't do it that way. Make just an array holding
>exceptions to the main array be shared. Then periodically update the
>(local) main array based on the shared exception array.
I actually did something like that, but used a string instead of an
array. It greately sped things up. Each process merely looks for a
change to the string and if there are any it then decodes the string
and modifies its internal list.
>> Basicly each process is iterating over a list (array) and every so
>> often a process gets a result that means that item no longer needs to
>> be ran, so it should remove it from it's list and notify the other
>> processes so that they can remove it from theirs as well.
>
>What are the consequences if a process doesn't get the message and runs
>that task anyway? Is it just a waste of resources, or is it fatal to the
>whole thing you are trying to do?
>
>How many such removal messages do you generate, in relation to the full
>size of the array to iterate over? If small, it would probably be most
>efficient to just run even the "removed" tasks and then filter them out in
>post-processing.
It's not fatal, but it wastes the request. Each request has a chance
of getting a product for my company. So, concentrating on products
that are still available and not wasting requests on taken products
will improve our chances of getting products 10-20% or so.
>How does it work that your processes are iterating over an array which
>is changing during the iteration? That seems like a problem waiting to
>happen.
I didn't like that ethior, so instead of removing an element I set it
to "". Then the main loop has a line:
unless ($number) {next}
to skip over removed entries. The extra time for the partial iteration
is tiny compared to the other factors so this seemed the most elegant
solution.
>> Whith
>> IPC::Shareable it works nicely as when one process removes the item,
>> all the others have it removed also, but it appers that the shareable
>> module is slowing things down considerablly (CPU usage doubled).
>>
>> If someone could point me in the right direction, that would be great.
>> I have an idea for speeding up shareable a little, but it's still not
>> going to be fast.
>
>Each process could keep their own private version of the array, and
>only refresh it against the shared version (or against a shared
>exception list) every now and then. How often it would do this refresh
>would depend on the cost of the refresh vs. the wasted effort that goes
>into processing tasks that have been removed since the last refresh.
I have it do it for every request. Durring actual conditions the
requests slow down to a 10 second response which is all the time in
the world for this use.
>When I had to do something sort of like this I used a much simpler
>approach. Each parallel child process was given a batch to do, then would
>reported back to the house-keeper on which things should be removed, and
>then exited. The house-keeper would process those exception to make a new
>set of batches, and spawn another round of child processes.
That would work nicely, but timing is very important and just bringing
up 50 processes can take up to ten minutes if they are really active.
I thought of using the parent/child communication methods, but I'd
rather do it outright as I am already down this design leg.
>Xho
>
>--
>-------------------- http://NewsReader.Com/ --------------------
>Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 10 Jan 2005 21:01:35 GMT
From: whansen_at_corporate-image_dot_com@us.com
Subject: Re: IPC looking for simple/best way to communicate
Message-Id: <41e2e98a.3288201@news.sonic.net>
So your advice boils down to, don't ask questions on Usenet?
some stats:
1.7GHz Processor
1024 MB
2x80GB raid 1
500 GB montly badwith
10mbps internet connection
Mandrake 9.2
Perl 5.8.1
Speed is important, each process should be able to iterate at 3 per
second with the entire lot comeing in at 150 itterations per second,
although under actual war conditions this slows down to 10 seconds per
cycle or about 5 iterations per second for all processes.
Cpu utalization is important as the current Shareable implementation
uses about 2% of CPU running at 3 requests per second. 50 processes
meaning we're at very high CPU usage. However this drops consdierably
durring the actual run time when things slow down to 10 seconds per
response.
Memory is important as it is limited. The current processes use less
than 1% of the gig memory each. There is about 400megs free on the
system when they are all running. This could be a factor if we
increase the 50 processes to 200 or so. We are unable to upgrade
memory without a new server and additional costs, so memory is the
major factor lmiiting the number of processes we run.
> - portability,
should work on any reasonable linux box with perl
> - maintainance,
the code you write needs its oil changed every once in a while?
> - scalability,
more processes doing the same thing as described above.
> - development time,
not a huge factor. Getting it done right is more important
> - development costs,
not really a factor. I'm getting paid
> - ease of deployment,
sftp
> - simplicity,
so long as I can figgure it out
> - operational costs,
not even going to try to figgure that out, doesn't matter or is
insignificant.
On 08 Jan 2005 20:33:03 GMT, Abigail <abigail@abigail.nl> wrote:
>whansen_at_corporate-image_dot_com@us.com
>(whansen_at_corporate-image_dot_com@us.com) wrote on MMMMCXLVII September MCMXCIII in <URL:news:41ded263.3951491@news.sonic.net>:
>() I'm trying to find the best way to do something.
>
>This is an example of a really bad question. Who's going to decide what
>the "best way" to do something is? All you do is describe a problem,
>but you don't say *ANYTHING* at all which even remotely hints of what
>will be a good way for you, let alone the best way.
>
>Do you want a solution that is optimized for:
>
> - speed,
> - memory,
> - portability,
> - maintainance,
> - scalability,
> - development time,
> - development costs,
> - ease of deployment,
> - simplicity,
> - operational costs,
> - ...
>
>?
>
>Note that none of these can be answered without knowing a lot of your
>development and operation environments.
>
>If you want to know the "best way" (of anything, not this problem),
>hire a good consultant. Don't go to Usenet for answers.
>
>
>
>Abigail
>--
>$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
>$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
>-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Mon, 10 Jan 2005 21:19:35 GMT
From: whansen_at_corporate-image_dot_com@us.com
Subject: Re: IPC looking for simple/best way to communicate
Message-Id: <41e2ee32.4481027@news.sonic.net>
I'm starting to think that Shareable may be the way to go unless I
want to go to a server/client connection. I already mentioned that I
have found a way to use Shareable for communication instead of for the
actual list and that sped things up a great deal.
A server would work like this:
Server accepts connections on given port. Connection can be just a
request or a request with a removal. Sever accepts any removals and
removes them from it's list and then replies with the next data item
from it's list for the client to run. Disadvantage - each process must
connect to the server once for each itteration. What happens if the
server is busy with another process. Advantage - Very exact control
over the list. The server can easily make sure the list is run evenly
where the current model uses a randomization so that the processes
won't all be running the same list in synyc.
Now the server process would be very simple. It just maintains the
list and gives out the next element. But I wonder if a single process
could deal well with 150 or more requests per second. I think I'd just
have to program it and give it a try. Can anyone comment on this? What
would happen if the server was not avialble? I'm assuming the
requesting process would just wait for the port to be clear. Again
this would be much less important in the actual use when it slows down
to 5 requests per second.
On Fri, 07 Jan 2005 12:29:16 -0800, Jim Gibson
<jgibson@mail.arc.nasa.gov> wrote:
>In article <41ded263.3951491@news.sonic.net>,
><whansen_at_corporate-image_dot_com@us.com> wrote:
>
>> I'm trying to find the best way to do something. I've got 50 processes
>> (may have 200 soon) that need to broadcast simple messages to each of
>> them. I tried doing this with sockets, but although I was able to get
>> them to read a socket without halting succesfully I found that when
>> one process reads a socket it removes the message from the socket and
>> the other processes don't see it. My current solution works using
>> IPC::Shareable, but is slow and hogs memory as well as the CPU.
>> Shareable lets you set a variablle that multiple programs can read and
>> write to. In my case they read and write to the list that they all run
>> off.
>
>Sockets implement a data connection between two processes, potentially
>on different systems. Three or more processes cannot share a socket.
>When you write data to a socket that connects two processes, only the
>reading process will get the data. Any other process will be reading
>from its own unique socket and will not receive the data. You would
>have to connect each pair of processes with a unique socket pair. For
>200 processes, that would mean 39800 separate sockets.
>
>A better approach using sockets would implement a single dispatcher
>process that sends the current list to each of the 200 analysis
>processes (or whatever you want to call them). Each analysis process
>would send the updated list to the central dispatching process.
>
>If all of your processes are on the same system, then internet protocol
>(IP) domain sockets impose a network overhead that is unnecessary. You
>are better off using Unix domain sockets (assuming you are on Unix,
>that is).
>
>However, it would seem for this application that shared memory is the
>fastest way to go, and IPC::Shareable gives you access to shared memory
>(disclaimer: I have not used it). If you are having performance
>problems, then can try to optimize your use of shared memory. One
>suggestion would be to make a local copy of the shared memory list and
>iterate over the local copy. This works if you can use an old list when
>the list gets modified for a short period of time. You can check
>periodically (using another shared variable perhaps) if the list has
>been modified and fetch the new version. You can use a simple counter
>to indicate when the list has been updated.
>
>If you can't get IPC::Shareable to work, you can put the list into a
>file, periodically read the file if it is unlocked, and have any
>process that wants to update the file lock it and re-write it.
>
>
>----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
>http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
>---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Mon, 10 Jan 2005 14:00:47 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: IPC looking for simple/best way to communicate
Message-Id: <100120051400476626%jgibson@mail.arc.nasa.gov>
In article <41e2ee32.4481027@news.sonic.net>,
<whansen_at_corporate-image_dot_com@us.com> wrote:
Top-posting fixed (please don't top-post).
>
> On Fri, 07 Jan 2005 12:29:16 -0800, Jim Gibson
> <jgibson@mail.arc.nasa.gov> wrote:
>
> >In article <41ded263.3951491@news.sonic.net>,
> ><whansen_at_corporate-image_dot_com@us.com> wrote:
> >
[ previous advice on sockets vs. shared memory snipped]
> >
> I'm starting to think that Shareable may be the way to go unless I
> want to go to a server/client connection. I already mentioned that I
> have found a way to use Shareable for communication instead of for the
> actual list and that sped things up a great deal.
>
> A server would work like this:
>
> Server accepts connections on given port. Connection can be just a
> request or a request with a removal. Sever accepts any removals and
> removes them from it's list and then replies with the next data item
> from it's list for the client to run. Disadvantage - each process must
> connect to the server once for each itteration. What happens if the
> server is busy with another process. Advantage - Very exact control
> over the list. The server can easily make sure the list is run evenly
> where the current model uses a randomization so that the processes
> won't all be running the same list in synyc.
>
> Now the server process would be very simple. It just maintains the
> list and gives out the next element. But I wonder if a single process
> could deal well with 150 or more requests per second. I think I'd just
> have to program it and give it a try. Can anyone comment on this? What
> would happen if the server was not avialble? I'm assuming the
> requesting process would just wait for the port to be clear. Again
> this would be much less important in the actual use when it slows down
> to 5 requests per second.
A server can handle only a limited number of queued requests for a
socket connection. The default is 5, The actual maximum number is
system-dependent and may be set by a parameter to the listen()
function. This is the number of connections that are pending but
incomplete. It takes an exchange of 3 IP packets to complete a
connection. If a client attempts to connect to the server while the
number of pending, incomplete connections is equal to the maximum, the
client will likely get a "connection refused" response from the server.
So whether or not the socket server approach will work depends upon 1)
how often a client requests a connection, and 2) how long it takes the
server to complete a client request. Only you have the answers to those
questions.
My money is still on a shared memory solution.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Mon, 10 Jan 2005 09:25:32 -0800
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: Is zero even or odd?
Message-Id: <34fs4kF4a43jiU1@individual.net>
Earle Jones wrote:
> In article <34d3vdF47dpkeU1@individual.net>,
> "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com> wrote:
>
>> vonroach wrote:
>>> On Fri, 31 Dec 2004 09:11:43 -0800, "Alfred Z. Newmane"
>>> <a.newmane.remove@eastcoastcz.com> wrote:
>>>
>>>> What in the sam-hell are you on? Thats what I've /BEEN/ saying, ya
>>>> trollimous maximus;
>>>>
>>>> I've been saying it's undefined.
>>>
>>> Then there was the trifle of your ambiguous apple question or
>>> should I say troll.
>>
>> I never asked the apple question, that was someone else. No wonder
>> you're so mixed up, you can't even put a statement with the correct
>> name!
>
> *
> Zero is even.
>
> 1. It is divisible by two without a remainder.
> 2. It occurs between two odd integers.
>
> earle
> *
Exactly. And if I may expand on that:
Remember that:
even + even = even (eg: 2 + 4 = 6)
and
odd + even = odd (eg: 2 + 3 = 5)
and
odd + odd = even (eg: 3 + 5 = 8)
Consider:
0 + 2 = 2
- Even result, so zero must be Even; e+e=e rule.
But:
0 + 1 = 1
- Odd result, so 0 cannot be odd.
- Follows the e+o=o rule, again showing 0 must be Even.
------------------------------
Date: Mon, 10 Jan 2005 15:39:25 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: passing $cgi object in hash.
Message-Id: <slrncu5tgd.8bi.tadmc@magna.augustmail.com>
sam <sam.wun@authtec.com> wrote:
> sam wrote:
>> I would like to pass the $cgi object to a subroutine from a hash object,
The hash you show below is NOT an "object", it has not been
bless()ed into any class. It is a plain old hash.
>> sub testing
> my %_hash = ('cgi' => $cgi);
> test($obj1,$obj2, "my", "string", \%_hash);
Errr, I thought the subroutine was named testing(), what is
this test() subroutine?
testing($obj1,$obj2, "my", "string", $_hash{cgi});
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 10 Jan 2005 09:21:52 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl tutorial
Message-Id: <slrncu57cg.7j4.tadmc@magna.augustmail.com>
sandhyapochiraju@gmail.com <sandhyapochiraju@gmail.com> wrote:
> I would like to learn PERL.
The 1st thing to learn is that you want to learn Perl, it
is not really an acronym.
> Please let
> me know about some sites which give free and easy to understand
> tutorials on PERL.
http://learn.perl.org
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Jan 2005 08:37:53 -0800
From: "g3000" <carlton_gregory@yahoo.com>
Subject: Re: specifying use strict
Message-Id: <1105375073.739163.144100@c13g2000cwb.googlegroups.com>
thanks joe
I changed my code to this as Uri recommended
( this is when the config file already exists )
$configtime = localtime;
$currBackupFolder = makeFileSystem();
%rep = ParseConfig (-ConfigFile => "backupRepository.conf");
$rep{$backup_id} = {TIMESTAMP => $configtime,
SERVER => "SAMSDEV",
BACKUP_LOCATION => $currBackupFolder,
ORAHOME => $ORAHOME,
ORASID => $ORASID,
DBFILES => $dblocation
};
SaveConfig("backupRepository.conf",\%rep);
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7627
***************************************