[28087] in Perl-Users-Digest
Perl-Users Digest, Issue: 9451 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 00:05:43 2006
Date: Tue, 11 Jul 2006 21:05:05 -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, 11 Jul 2006 Volume: 10 Number: 9451
Today's topics:
finding perl info on google can be hard ilikesluts@gmail.com
Re: finding perl info on google can be hard xhoster@gmail.com
Re: finding perl info on google can be hard <sherm@Sherm-Pendleys-Computer.local>
Re: finding perl info on google can be hard <john@castleamber.com>
Re: finding perl info on google can be hard <sherm@Sherm-Pendleys-Computer.local>
Re: finding perl info on google can be hard <jurgenex@hotmail.com>
Re: finding perl info on google can be hard ilikesluts@gmail.com
Re: finding perl info on google can be hard <benmorrow@tiscali.co.uk>
Re: Get Invoked Script Location in Perl <benmorrow@tiscali.co.uk>
Re: Get Invoked Script Location in Perl <1usa@llenroc.ude.invalid>
Re: Help with grep function <xicheng@gmail.com>
Re: Help with grep function <kst-u@mib.org>
Perl +lists/unions/intersection: <orodionov@gmail.com>
Re: Perl +lists/unions/intersection: <1usa@llenroc.ude.invalid>
Re: Perl +lists/unions/intersection: <orodionov@gmail.com>
Re: Perl +lists/unions/intersection: <1usa@llenroc.ude.invalid>
Re: Problem with Multi- threaded Server xhoster@gmail.com
Re: Problem with Multi- threaded Server <1usa@llenroc.ude.invalid>
Re: Problem with Multi- threaded Server <benmorrow@tiscali.co.uk>
Re: processing large numbers/values/figures <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Jul 2006 18:18:19 -0700
From: ilikesluts@gmail.com
Subject: finding perl info on google can be hard
Message-Id: <1152667098.964373.179210@b28g2000cwb.googlegroups.com>
Hi,
So I wanted to know what -r did and I had a hard time finding out on
google because it doesn't search for characters like '-'. So since
perl is full of strange characters like this how do you people find out
the info you need?
------------------------------
Date: 12 Jul 2006 01:21:20 GMT
From: xhoster@gmail.com
Subject: Re: finding perl info on google can be hard
Message-Id: <20060711212507.984$SU@newsreader.com>
ilikesluts@gmail.com wrote:
> Hi,
> So I wanted to know what -r did and I had a hard time finding out on
> google because it doesn't search for characters like '-'.
I feel your pain. I was trying to look up how to reset $^T to make -M keep
up to date, and google wasn't helping me much at all. I finally got it
just by googling and BASETIME and little trial and error.
> So since
> perl is full of strange characters like this how do you people find out
> the info you need?
In this case, by using the perldocs:
perldoc -f -r
If that isn't enough, I guess I would google on something like
"Perl file test readable"
But I wish that google would intepret putting something in quotes would as
meaning that that exact sequence of characters, including puntcuation, was
needed.
Xho
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 11 Jul 2006 21:29:18 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: finding perl info on google can be hard
Message-Id: <m2odvvhaq9.fsf@Sherm-Pendleys-Computer.local>
ilikesluts@gmail.com writes:
> So I wanted to know what -r did and I had a hard time finding out on
> google because it doesn't search for characters like '-'.
Why were you searching google in the first place? Is there something about
the docs that come with Perl that you didn't grok?
> perl is full of strange characters like this how do you people find out
> the info you need?
perldoc -f -r
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 12 Jul 2006 02:52:03 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: finding perl info on google can be hard
Message-Id: <Xns97FDDE718E76Bcastleamber@130.133.1.4>
Sherm Pendley <sherm@Sherm-Pendleys-Computer.local> wrote:
> ilikesluts@gmail.com writes:
>
>> So I wanted to know what -r did and I had a hard time finding out on
>> google because it doesn't search for characters like '-'.
>
> Why were you searching google in the first place? Is there something
> about the docs that come with Perl that you didn't grok?
I did yesterday :-) Does seek set $! or not? (According to Programming
Perl is does, but perldoc -f seek didn't say so).
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: Tue, 11 Jul 2006 23:12:06 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: finding perl info on google can be hard
Message-Id: <m2hd1nh5yx.fsf@Sherm-Pendleys-Computer.local>
John Bokma <john@castleamber.com> writes:
> Does seek set $! or not? (According to Programming
> Perl is does, but perldoc -f seek didn't say so).
That's a damn good question! I ran a test trying to seek(FILE, 50, 0) in
an 0-byte read-only file - the seek didn't even *fail*, much less set $! -
it just happily and silently returned a 1.
So I tried again, this time seek(FILE, -50, 0) - obvious nonsense, trying
to seek to position -50 from the beginning. That time it returned 0 and set
$! to "Invalid argument".
So it looks like seek does some basic sanity checking for arguments that
are nonsensical regardless of the file size, but doesn't do a bounds check
against the actual file size. That makes sense in the case of a writable
file which can be grown to fit the new position, but for a read-only file
it's completely non-intuitive.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Wed, 12 Jul 2006 03:21:22 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: finding perl info on google can be hard
Message-Id: <SUZsg.14827$Wh7.7395@trnddc07>
ilikesluts@gmail.com wrote:
> So I wanted to know what -r did and I had a hard time finding out
I wonder why? 'perldoc -f -r' seems to be very straight forward.
> on
> google because it doesn't search for characters like '-'.
Where did you get the idea that Google has anything to do with Perl?
> So since
> perl is full of strange characters like this how do you people find
> out the info you need?
They check the Perl documentation, I suppose?
jue
------------------------------
Date: 11 Jul 2006 20:39:48 -0700
From: ilikesluts@gmail.com
Subject: Re: finding perl info on google can be hard
Message-Id: <1152675588.323774.200020@35g2000cwc.googlegroups.com>
Hi Jurgen Exner,
google (http://www.google.com) is a search engine and is useful for
finding information on all sorts of topics, not just Perl. You should
check it out.
J=FCrgen Exner wrote:
> ilikesluts@gmail.com wrote:
>
> Where did you get the idea that Google has anything to do with Perl?
------------------------------
Date: Wed, 12 Jul 2006 04:49:27 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: finding perl info on google can be hard
Message-Id: <738eo3-ne3.ln1@osiris.mauzo.dyndns.org>
Quoth Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>:
> John Bokma <john@castleamber.com> writes:
>
> > Does seek set $! or not? (According to Programming
> > Perl is does, but perldoc -f seek didn't say so).
>
> That's a damn good question! I ran a test trying to seek(FILE, 50, 0) in
> an 0-byte read-only file - the seek didn't even *fail*, much less set $! -
> it just happily and silently returned a 1.
>
> So I tried again, this time seek(FILE, -50, 0) - obvious nonsense, trying
> to seek to position -50 from the beginning. That time it returned 0 and set
> $! to "Invalid argument".
>
> So it looks like seek does some basic sanity checking for arguments that
> are nonsensical regardless of the file size, but doesn't do a bounds check
> against the actual file size. That makes sense in the case of a writable
> file which can be grown to fit the new position, but for a read-only file
> it's completely non-intuitive.
From my lseek(2):
| The lseek function allows the file offset to be set beyond the end of
| the existing end-of-file of the file (but this does not change the size
| of the file). If data is later written at this point, subsequent reads
| of the data in the gap return bytes of zeros (until data is actually
| written into the gap).
So Perl is just reporting what the OS does.
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
benmorrow@tiscali.co.uk
------------------------------
Date: Tue, 11 Jul 2006 23:34:30 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Get Invoked Script Location in Perl
Message-Id: <mkldo3-6i1.ln1@osiris.mauzo.dyndns.org>
Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> David Squire <David.Squire@no.spam.from.here.au> wrote in
> news:e90unf$da$2@gemini.csx.cam.ac.uk:
>
> > fiorentico@gmail.com wrote:
> >>
> >> I'd like to obtain the location of the script I am calling. E.g.
> >>
> >> If I am calling
> >>
> >> perl X:\script.pl
> >>
> >> I want to obtain "X:\". How do I do that?
> >
> > See perldoc perlvar. Look for the string "Contains the name of the
> > program being executed".
>
> See perldoc FindBin.
>
> AFAIK, the contents of $0 are OS dependent.
They are, and IIRC FindBin doesn't always work on Windows (in
particular, if the program was found through the PATH then $0 contains
just the program name, and FindBin fails). They may have fixed it by
now, of course... :)
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
benmorrow@tiscali.co.uk (Kate Rusby)
------------------------------
Date: Wed, 12 Jul 2006 00:21:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Get Invoked Script Location in Perl
Message-Id: <Xns97FDCF29CB0EDasu1cornelledu@127.0.0.1>
Ben Morrow <benmorrow@tiscali.co.uk> wrote in news:mkldo3-6i1.ln1
@osiris.mauzo.dyndns.org:
>
> Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
>> David Squire <David.Squire@no.spam.from.here.au> wrote in
>> news:e90unf$da$2@gemini.csx.cam.ac.uk:
>>
>> > fiorentico@gmail.com wrote:
>> >>
>> >> I'd like to obtain the location of the script I am calling. E.g.
>> >>
>> >> If I am calling
>> >>
>> >> perl X:\script.pl
>> >>
>> >> I want to obtain "X:\". How do I do that?
>> >
>> > See perldoc perlvar. Look for the string "Contains the name of the
>> > program being executed".
>>
>> See perldoc FindBin.
>>
>> AFAIK, the contents of $0 are OS dependent.
>
> They are, and IIRC FindBin doesn't always work on Windows (in
> particular, if the program was found through the PATH then $0 contains
> just the program name, and FindBin fails). They may have fixed it by
> now, of course... :)
I was never aware of any problems, but I'll take your word for it.
Whatever it was, it seems to have been fixed:
D:\Src> perl -v
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 25 registered patches, see perl -V for more detail)
Copyright 1987-2006, Larry Wall
Binary build 817 [257965] provided by ActiveState
http://www.ActiveState.com
Built Mar 20 2006 17:54:25
D:\Src> perl -MFindBin -e "print $FindBin::VERSION"
1.47
D:\Src> cat c:\opt\util\echopath.pl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd;
use FindBin qw( $Bin );
my %h = (
'Working directory' => getcwd(),
'Program location' => $Bin,
);
print "$_ = $h{$_}\n" for keys %h;
D:\Src> echopath
Program location = c:/opt/util
Working directory = D:/Src
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 11 Jul 2006 15:42:17 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Help with grep function
Message-Id: <1152657737.926772.180630@m79g2000cwm.googlegroups.com>
Keith Thompson wrote:
> "Xicheng Jia" <xicheng@gmail.com> writes:
> >
> > my $count = grep /ERROR:(?!\s*Virtual)/i, <$fh>;
>
> Note that it's not really necessary to force everything into a single
> regular expression. For example:
>
> my $count = grep { /ERROR:/i && !/Virtual/i } <$fh>;
>
these two statements may do different things. i.e. that single regex
will match:
ERROR: TEST Virtual
If OP wants to do grep -v, then my previous solution is not correct. in
a single regex, it can be:
my $count = grep /^(?=.*?ERROR)(?!.*Virtual)/i, <$fh>;
Xicheng
------------------------------
Date: Wed, 12 Jul 2006 03:36:57 GMT
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Help with grep function
Message-Id: <lnd5cbcx47.fsf@nuthaus.mib.org>
"Xicheng Jia" <xicheng@gmail.com> writes:
> Keith Thompson wrote:
>> "Xicheng Jia" <xicheng@gmail.com> writes:
>> >
>> > my $count = grep /ERROR:(?!\s*Virtual)/i, <$fh>;
>>
>> Note that it's not really necessary to force everything into a single
>> regular expression. For example:
>>
>> my $count = grep { /ERROR:/i && !/Virtual/i } <$fh>;
>>
>
> these two statements may do different things. i.e. that single regex
> will match:
>
> ERROR: TEST Virtual
>
> If OP wants to do grep -v, then my previous solution is not correct. in
> a single regex, it can be:
>
> my $count = grep /^(?=.*?ERROR)(?!.*Virtual)/i, <$fh>;
You're right. The OP didn't provide enough information to tell us
which solution actually matches his needs, if any.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
------------------------------
Date: 11 Jul 2006 19:13:06 -0700
From: "oleg" <orodionov@gmail.com>
Subject: Perl +lists/unions/intersection:
Message-Id: <1152670386.786062.215730@i42g2000cwa.googlegroups.com>
Hello,
Could you please help me to solve the following problem.
Rules:
1) There "N" number of lists. Each list has W(N) number of elements
2) Each list can be fully independent of other lists or it can have
intersection with one or more other lists or it can be identical to one
or more other lists.
3) I need to combine these lists into the new "M" number of lists
of size that is less then K. The goal is to produce the smallest
possible number of lists
4) Size K is greater then any one size of original lists
5) New lists must always include all elements found in original lists
minus the duplicates.
Here is an example:
Combine seven lists below into new lists. New lists must contain less
then 10 elements
list_1: { a, b, c, d ,e }
list_2: { c, d, a, g }
list_3: { a, g, s, h, y }
list_4: { t, r, n, l, o }
list_5: { c, f, g, s, w, y }
list_6: { n, y, r, s }
list_7: { k, b, s }
list_1+list_2: { a, b, c, d, e, g }
list_3 + list_5; { a, g, s, h, y, c, f, w, y }
list_4 + list_6 + list_7: { t, r, n, l, o, y, s, k, b }
Thank you!
Oleg
------------------------------
Date: Wed, 12 Jul 2006 02:21:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl +lists/unions/intersection:
Message-Id: <Xns97FDE382C51F1asu1cornelledu@127.0.0.1>
"oleg" <orodionov@gmail.com> wrote in
news:1152670386.786062.215730@i42g2000cwa.googlegroups.com:
> Could you please help me to solve the following problem.
> Rules:
This sounds like homework to me.
> 1) There "N" number of lists. Each list has W(N) number of
> elements 2) Each list can be fully independent of other lists or
> it can have intersection with one or more other lists or it can be
> identical to one or more other lists.
> 3) I need to combine these lists into the new "M" number of lists
> of size that is less then K. The goal is to produce the smallest
> possible number of lists
That would be a single list, wouldn't it?
> 4) Size K is greater then any one size of original lists
This requirement does not preclude producing a single list.
> 5) New lists must always include all elements found in original
> lists minus the duplicates.
Ditto.
> Here is an example:
>
> Combine seven lists below into new lists. New lists must contain less
> then 10 elements
Why? Where did that requirement come from?
> list_1: { a, b, c, d ,e }
> list_2: { c, d, a, g }
> list_3: { a, g, s, h, y }
> list_4: { t, r, n, l, o }
> list_5: { c, f, g, s, w, y }
> list_6: { n, y, r, s }
> list_7: { k, b, s }
>
> list_1+list_2: { a, b, c, d, e, g }
> list_3 + list_5; { a, g, s, h, y, c, f, w, y }
> list_4 + list_6 + list_7: { t, r, n, l, o, y, s, k, b }
How did you come up with these magic lists?
Please read and follow the posting guidelines for this group. Post a
more complete statement of the problem, along with your best attempt to
solve it (following the guidelines).
Do browse the FAQ list before you post. In particular,
perldoc -q intersection
perldoc -q duplicate
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 11 Jul 2006 20:00:02 -0700
From: "oleg" <orodionov@gmail.com>
Subject: Re: Perl +lists/unions/intersection:
Message-Id: <1152673202.092297.64310@75g2000cwc.googlegroups.com>
A. Sinan Unur wrote:
> "oleg" <orodionov@gmail.com> wrote in
> news:1152670386.786062.215730@i42g2000cwa.googlegroups.com:
>
> > Could you please help me to solve the following problem.
> > Rules:
>
> This sounds like homework to me.
>
> > 1) There "N" number of lists. Each list has W(N) number of
> > elements 2) Each list can be fully independent of other lists or
> > it can have intersection with one or more other lists or it can be
> > identical to one or more other lists.
> > 3) I need to combine these lists into the new "M" number of lists
> > of size that is less then K. The goal is to produce the smallest
> > possible number of lists
>
> That would be a single list, wouldn't it?
>
> > 4) Size K is greater then any one size of original lists
>
> This requirement does not preclude producing a single list.
>
> > 5) New lists must always include all elements found in original
> > lists minus the duplicates.
>
> Ditto.
>
> > Here is an example:
> >
> > Combine seven lists below into new lists. New lists must contain less
> > then 10 elements
>
> Why? Where did that requirement come from?
>
> > list_1: { a, b, c, d ,e }
> > list_2: { c, d, a, g }
> > list_3: { a, g, s, h, y }
> > list_4: { t, r, n, l, o }
> > list_5: { c, f, g, s, w, y }
> > list_6: { n, y, r, s }
> > list_7: { k, b, s }
> >
> > list_1+list_2: { a, b, c, d, e, g }
> > list_3 + list_5; { a, g, s, h, y, c, f, w, y }
> > list_4 + list_6 + list_7: { t, r, n, l, o, y, s, k, b }
>
> How did you come up with these magic lists?
>
> Please read and follow the posting guidelines for this group. Post a
> more complete statement of the problem, along with your best attempt to
> solve it (following the guidelines).
>
> Do browse the FAQ list before you post. In particular,
>
> perldoc -q intersection
> perldoc -q duplicate
>
> Sinan
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
I guess I made it look like school homework, but it is not.
In real world, I have "bunches" of signals coming from hardware
substate machines ( very large state machine split up into many smaller
ones) . I want to write a script to equalize these signals into the
least number of 21bit chunks to minimize the muxing.
I did it by hand once, but state machine keeps changing and so I would
rather automate procedure. I already wrote a perl script that extracts
the signals and build the lists. Now, I just need the right algorithm
for the lists
------------------------------
Date: Wed, 12 Jul 2006 03:07:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl +lists/unions/intersection:
Message-Id: <Xns97FDEB68289D8asu1cornelledu@127.0.0.1>
"oleg" <orodionov@gmail.com> wrote in news:1152673202.092297.64310@
75g2000cwc.googlegroups.com:
> A. Sinan Unur wrote:
>> "oleg" <orodionov@gmail.com> wrote in
>> news:1152670386.786062.215730@i42g2000cwa.googlegroups.com:
>>
...
>> > list_1: { a, b, c, d ,e }
>> > list_2: { c, d, a, g }
>> > list_3: { a, g, s, h, y }
>> > list_4: { t, r, n, l, o }
>> > list_5: { c, f, g, s, w, y }
>> > list_6: { n, y, r, s }
>> > list_7: { k, b, s }
>> >
>> > list_1+list_2: { a, b, c, d, e, g }
>> > list_3 + list_5; { a, g, s, h, y, c, f, w, y }
>> > list_4 + list_6 + list_7: { t, r, n, l, o, y, s, k, b }
>>
>> How did you come up with these magic lists?
>>
>> Please read and follow the posting guidelines for this group. Post a
>> more complete statement of the problem, along with your best attempt
>> to solve it (following the guidelines).
<SNIP>
Don't quote signatures.
> I guess I made it look like school homework, but it is not.
>
> In real world, I have "bunches" of signals coming from hardware
> substate machines ( very large state machine split up into many
> smaller ones) . I want to write a script to equalize these signals
> into the least number of 21bit chunks to minimize the muxing.
Please do read and follow the posting guidelines. Do not full-quote.
Trim quoted material appropriately in your response.
> I did it by hand once, but state machine keeps changing and so I
> would rather automate procedure. I already wrote a perl script that
> extracts the signals and build the lists. Now, I just need the right
> algorithm for the lists
Well, as I said, explain what you want to do clearly, and consistently,
and show your best attempt to solve the problem.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 12 Jul 2006 00:23:56 GMT
From: xhoster@gmail.com
Subject: Re: Problem with Multi- threaded Server
Message-Id: <20060711202743.217$qZ@newsreader.com>
Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 10 Jul 2006, xhoster@gmail.com wrote:
>
> Ted Zlatanov <tzz@lifelogs.com> wrote: > On 30 Jun 2006,
> xhoster@gmail.com wrote: >
> >>> Or just fork instead of threads. Ask your boss "How much are you
> >>> willing to spend to accomplish your stupid and arbitrary
> >>> requirements?"
> >>
> >> I don't think that's a good question.
> >
> > I don't think it is universally, but in this case it seems like it.
>
> OK, let me rephrase. The way you stated it, that's a terrible
> question :) Most people wouldn't ask that from anyone in a business
> environment, let alone their boss.
I think it goes without saying that you have to translate things into
BusinessSpeak, or Mongolian, or whatever the local language is, when you
relay things to others. That said, I'd much rather have a subordinate
correctly insult my requirements when they have a better alternative,
rather than blithely waste weeks of time trying implement my
(mis)conception.
Or at least any subordinate whom I had to micromanage so much that I wasn't
interested in spirited push back from them, I certainly wouldn't want them
going to usenet, rather than to me, to get advice. But I don't see why I
would want a report like that anyway.
>
> Also I wasn't looking to discuss the particulars of Perl threads and
> why they may sometimes be better; my list was just suggestions. The
> point was that threads are not *always* a bad idea, and when you don't
> know the full story (which I'm sure you don't, unless you work with
> the OP) it's more helpful to offer gentle suggestions than to be
> forceful.
I'm sure I don't know the full story, but I have to work with what I have,
and what I have indicated no need for threads. The gentler suggestions
didn't seem to work. Either the boss is an idiot or the boss has good
reason to use threads but won't shared them with the OP and hence with us.
> >> Here's a list of places where threads are usually better than
> >> fork():
> >>
> >> - limited memory
> >
> > How does that work out in threads favor over fork? Perl's threads
> > suck at memory, and on most systems forks use COW, which makes
> > static structures quite compact.
>
> Do some benchmarks if you like. I'm well-aware that fork() is better
> in many ways, but I doubt you'll get better memory performance with
> it. If you find otherwise, I'm all ears.
perl -le 'use threads; my @x=1..100_000; foreach (1..10000) { async {
sleep}->detach(); warn $_ unless $_%100; }'
The above started swapping itself to death between 400 and 500 (and it took
precious long even to get to 400).
perl -le 'use threads; my @x=1..100_000; foreach (1..10000) {fork or sleep;
warn $_ unless $_%100; }'
This one rapidly ran up to 4500, at which point I killed it to prevent
running out of processes.
> >> - threads need to collaborate, especially with semaphores and timing
> >
> > Sure, but I don't see any indication that that is the case here.
>
> I am not talking about the threaded web server the OP wanted. These
> are places where threads are *usually* better than fork(), and
> my point was that you can't *always* say threads are worse or better
> than forking.
Right, but I wasn't saying that forks were always better, I was addressing
the case at hand, in which we can't even benchmark it to see because the
threading method seg faults. If you want to discuss generalities, I will
say that forks are almost always better than *Perl* threads when you don't
need extensive intercommunication.
>
> >> - lots of separate threads are expected
> >
> > I don't see a benefit of Perl's threads over forks in this respect,
> > either.
>
> Do some benchmarks if you like. I'm sure it takes fewer forks than
> threads to run out of resources, all other things being equal.
perl -le 'use threads; my @x=1..10; foreach (1..10000) { async {
sleep}->detach; warn $_ unless $_%100; }'
This seg-faulted at 1200, and took annoying long to get there.
perl -le 'use threads; my @x=1..10; foreach (1..10000) { fork or sleep;
warn $_;}'
This ran out of processes at 6100, very quickly.
This is perl, v5.8.0 built for i386-linux-thread-multi
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 12 Jul 2006 02:31:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <Xns97FDE52F3DEF3asu1cornelledu@127.0.0.1>
xhoster@gmail.com wrote in news:20060711202743.217$qZ@newsreader.com:
> perl -le 'use threads; my @x=1..10; foreach (1..10000) { async {
> sleep}->detach; warn $_ unless $_%100; }'
>
> This seg-faulted at 1200, and took annoying long to get there.
Under WinXP SP2, went aaaaalll the way up to 115 (quickly ;-).
>
> perl -le 'use threads; my @x=1..10; foreach (1..10000) { fork or
> sleep; warn $_;}'
>
> This ran out of processes at 6100, very quickly.
Hmmm ... Just stopped creating processes at 64. The program was still
running though. Had to use CTRL-C.
Under cygwin, it went up to 256.
Hmmm again.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 12 Jul 2006 04:45:57 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <ls7eo3-ne3.ln1@osiris.mauzo.dyndns.org>
Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> xhoster@gmail.com wrote in news:20060711202743.217$qZ@newsreader.com:
>
> > perl -le 'use threads; my @x=1..10; foreach (1..10000) { async {
> > sleep}->detach; warn $_ unless $_%100; }'
> >
> > This seg-faulted at 1200, and took annoying long to get there.
>
> Under WinXP SP2, went aaaaalll the way up to 115 (quickly ;-).
> >
> > perl -le 'use threads; my @x=1..10; foreach (1..10000) { fork or
> > sleep; warn $_;}'
> >
> > This ran out of processes at 6100, very quickly.
>
> Hmmm ... Just stopped creating processes at 64. The program was still
> running though. Had to use CTRL-C.
This is hardly a sensible benchmark on Win32, as fork is implemented
with ithreads anyway... it's interesting that they seem to be more
resource-hungry than using threads directly, though...
> Under cygwin, it went up to 256.
Do you know if cygwin provides its own fork emulation, and if perl uses
it or ithreads?
Ben
--
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks] benmorrow@tiscali.co.uk
------------------------------
Date: Tue, 11 Jul 2006 22:18:03 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: processing large numbers/values/figures
Message-Id: <Xns97FDBA4348934asu1cornelledu@127.0.0.1>
Lukas Ruf <ruf@rawip.org> wrote in news:slrneb80sd.oqe.ruf@pc-
4082.ethz.ch:
>> Tad McClellan [Tue, 11 Jul 2006 07:51:46 -0500]:
>>
>> Lukas Ruf <ruf@rawip.org> wrote:
>>
>> > $hsh{$key} += @record{$index};
>>
>>
>> You should always enable warnings when developing Perl code.
>>
>
> meanwhile, I do.
But you don't read them?
What is it that you intend to do with the statement above?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 9451
***************************************