[25312] in Perl-Users-Digest
Perl-Users Digest, Issue: 7557 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 22 18:15:42 2004
Date: Wed, 22 Dec 2004 15:15:11 -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 Wed, 22 Dec 2004 Volume: 10 Number: 7557
Today's topics:
Re: Output pipes <kimgh@pacbell.net>
Re: Output pipes <lv@aol.com>
Re: Output pipes xhoster@gmail.com
Re: Output pipes <kimgh@pacbell.net>
Re: Output pipes <nobull@mail.com>
Re: Output pipes <jgibson@mail.arc.nasa.gov>
Re: Regexp golf question <AaronJSherman@gmail.com>
Re: Regexp golf question <jase@dufair.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Dec 2004 19:27:45 GMT
From: Kim Helliwell <kimgh@pacbell.net>
Subject: Re: Output pipes
Message-Id: <BDEF0AB0.C63%kimgh@pacbell.net>
Guess I wasn't clear. Without the &, it works, but blocks after
each process and waits till the process exits before going on to
the next one.
Kim
On 12/22/04 10:59 AM, in article
221220041059068455%jgibson@mail.arc.nasa.gov, "Jim Gibson"
<jgibson@mail.arc.nasa.gov> wrote:
>
> Have you tried it without the '&'? The open should fork a child
> process, exec the xgraph program, which, if it accepts input from
> stdin, block waiting for input. Meanwhile, your program will continue
> to execute. Unfortunately, I don't have the xgraph program on my system
> to test it.
>
------------------------------
Date: Wed, 22 Dec 2004 14:03:40 -0600
From: l v <lv@aol.com>
Subject: Re: Output pipes
Message-Id: <41c9d294$1_1@127.0.0.1>
Kim Helliwell wrote:
> Guess I wasn't clear. Without the &, it works, but blocks after
> each process and waits till the process exits before going on to
> the next one.
>
> Kim
>
>
> On 12/22/04 10:59 AM, in article
> 221220041059068455%jgibson@mail.arc.nasa.gov, "Jim Gibson"
> <jgibson@mail.arc.nasa.gov> wrote:
>
>
>>Have you tried it without the '&'? The open should fork a child
>>process, exec the xgraph program, which, if it accepts input from
>>stdin, block waiting for input. Meanwhile, your program will continue
>>to execute. Unfortunately, I don't have the xgraph program on my system
>>to test it.
>>
>
>
Seems to me that the piped output would be placed after the & not before
it as you need. What are you piping into xgraph? Can you put your
input in the command vs piping it?
Like ... open(GRAPH, "xgraph $fileName &")
Len
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: 22 Dec 2004 20:23:00 GMT
From: xhoster@gmail.com
Subject: Re: Output pipes
Message-Id: <20041222152300.545$NX@newsreader.com>
Kim Helliwell <kimgh@pacbell.net> wrote:
> Guess I wasn't clear. Without the &, it works, but blocks after
> each process and waits till the process exits before going on to
> the next one.
What does this mean? What is "it"? It blocks "after each process"....
does what? After each process starts up? After each process gets bored?
After each process exits? Under normal circumstance, I would think "after
a process" would mean after the process finishes and exits. But if it
blocks after the process exits and then unblocks when the process
exits....well, I don't see how that is a problem.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 22 Dec 2004 20:38:04 GMT
From: Kim Helliwell <kimgh@pacbell.net>
Subject: Re: Output pipes
Message-Id: <BDEF1B2B.C73%kimgh@pacbell.net>
Once again, forgive the imprecision. I guess I should have included
the context from my original post as well.
I'm piping output from a Perl script to xgraph, which is an X-windows
graphing application (that is, it has a GUI). So when xgraph starts,
it doesn't quit until I mouse-click to close it. And, the script blocks
until that happens. Clear so far?
OK, I want to spawn about 16-32 of these xgraph processes all at once,
instead of one at a time. So I would like my script not to block waiting
for exit of the first xgraph process before spawning the next, and so on.
The question is: how can this be accomplished, short of handling the
fork/exec and IO redirection myself? Can this be accomplished at all
using the open(GRAPH, "| $cmd") syntax?
I hope that is a bit more clear.
Kim
On 12/22/04 12:23 PM, in article 20041222152300.545$NX@newsreader.com,
"xhoster@gmail.com" <xhoster@gmail.com> wrote:
> Kim Helliwell <kimgh@pacbell.net> wrote:
>> Guess I wasn't clear. Without the &, it works, but blocks after
>> each process and waits till the process exits before going on to
>> the next one.
>
> What does this mean? What is "it"? It blocks "after each process"....
> does what? After each process starts up? After each process gets bored?
> After each process exits? Under normal circumstance, I would think "after
> a process" would mean after the process finishes and exits. But if it
> blocks after the process exits and then unblocks when the process
> exits....well, I don't see how that is a problem.
>
> Xho
------------------------------
Date: Wed, 22 Dec 2004 21:13:22 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Output pipes
Message-Id: <cqcno4$rp6$1@sun3.bham.ac.uk>
Kim Helliwell wrote upside down (please don't do that, it is considered
rude):
> I'm piping output from a Perl script to xgraph, which is an X-windows
> graphing application (that is, it has a GUI). So when xgraph starts,
> it doesn't quit until I mouse-click to close it. And, the script blocks
> until that happens. Clear so far?
>
> OK, I want to spawn about 16-32 of these xgraph processes all at once,
> instead of one at a time. So I would like my script not to block waiting
> for exit of the first xgraph process before spawning the next, and so on.
>
> The question is: how can this be accomplished, short of handling the
> fork/exec and IO redirection myself? Can this be accomplished at all
> using the open(GRAPH, "| $cmd") syntax?
AFAIK it is impossible to close a file handle opened using the pipe
syntax (either explicitly or implicitly through reuse) without waiting.
(I even thought this was a FAQ but I can't find it). You need to do the
pipe/fork/exec by hand or by using a different filehandle for each
process. This is most easily achived using autovivified
pseudo-anonymous filehandles.
open(my $graph, '|-', $cmd ) or die $!;
push @graphs => $graph;
------------------------------
Date: Wed, 22 Dec 2004 13:57:45 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Output pipes
Message-Id: <221220041357451355%jgibson@mail.arc.nasa.gov>
In article <BDEF1B2B.C73%kimgh@pacbell.net>, Kim Helliwell
<kimgh@pacbell.net> wrote:
[top-posting fixed]
Please do not top-post. Put your responses FOLLOWING the statements to
which you are responding. Thanks.
> On 12/22/04 12:23 PM, in article 20041222152300.545$NX@newsreader.com,
> "xhoster@gmail.com" <xhoster@gmail.com> wrote:
>
> > Kim Helliwell <kimgh@pacbell.net> wrote:
> >> Guess I wasn't clear. Without the &, it works, but blocks after
> >> each process and waits till the process exits before going on to
> >> the next one.
> >
> > What does this mean? What is "it"? It blocks "after each process"....
> > does what? After each process starts up? After each process gets bored?
> > After each process exits? Under normal circumstance, I would think "after
> > a process" would mean after the process finishes and exits. But if it
> > blocks after the process exits and then unblocks when the process
> > exits....well, I don't see how that is a problem.
> >
> > Xho
>
> Once again, forgive the imprecision. I guess I should have included
> the context from my original post as well.
>
> I'm piping output from a Perl script to xgraph, which is an X-windows
> graphing application (that is, it has a GUI). So when xgraph starts,
> it doesn't quit until I mouse-click to close it. And, the script blocks
> until that happens. Clear so far?
>
> OK, I want to spawn about 16-32 of these xgraph processes all at once,
> instead of one at a time. So I would like my script not to block waiting
> for exit of the first xgraph process before spawning the next, and so on.
>
> The question is: how can this be accomplished, short of handling the
> fork/exec and IO redirection myself? Can this be accomplished at all
> using the open(GRAPH, "| $cmd") syntax?
>
> I hope that is a bit more clear.
It would be a lot clearer if you were to post a complete, working,
short-as-possible program that demonstrates the problem you are having.
For example, here is a program that spawns four x-windows processes:
#!/usr/local/bin/perl
#
use strict;
open( P1, "|xclock");
open( P2, "|xclock");
open( P3, "|xclock");
open( P4, "|xclock");
sleep(10);
print "Program finished\n";
This works fine on my system. All 4 processes display a window on my
screen. After 10 seconds, the main process terminates, and the 4 child
processes become zombies until I close their windows.
My system: Perl 5.8.6, Mac OS 10.3.7.
----== 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 =---
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: 22 Dec 2004 11:05:07 -0800
From: "ajs@ajs.com" <AaronJSherman@gmail.com>
Subject: Re: Regexp golf question
Message-Id: <1103742307.955044.322330@c13g2000cwb.googlegroups.com>
Anno Siegel wrote:
> ajs@ajs.com <AaronJSherman@gmail.com> wrote in comp.lang.perl.misc:
> > I wrote a program that generates passwords and
> > was discussing it with someone who asked if it could restrict its
> > results to those that alternate sides of the keyboard. This is a
> > feature I've been mulling for a while, but I suggested to him that
he
> > could just generate many passwords, and filter them using grep or
perl
> > or whatever.
> That doesn't seem to be an economical method to generate such
> passwords. The probability for a string to be alternating is
> 2**(length( $str) - 1). (Any character can be first, every
subsequent
> character has a 50% chance of being wrong.) So you'd generate about
> 128 passwords for an alternating one of length 8. And it gets
worse...
Yes, I know this, which is why I have not made it a feature in my
program yet. The way the program works, it would be hard to add a
control like this in an efficient way, as it would have to constrain
many decisions in strange ways. For example, you would limit the
dictionary for patterns that involve dictionary words to those words
which alternate, but then it gets dicey when you start replacing parts
of words later on. A simple example is replacing an "i" in "fish" with
"1"... ooops, now its no-longer valid. Even worse, if you replace the
"t" in "stay" with a "7", it now DOES alternate.
This is only a simple, contrived example, but it shows the difficulty.
The same problems come up in pseudo-word generation, inserting variable
lengths of random sequences and a bunch of other places.
I'll do this at some point, but it's probably a "2.0" sort of feature.
------------------------------
Date: Wed, 22 Dec 2004 14:15:37 -0500
From: Jason Dufair <jase@dufair.org>
Subject: Re: Regexp golf question
Message-Id: <j70k6rannza.fsf@dufair.org>
"ajs@ajs.com" <AaronJSherman@gmail.com> writes:
> I wrote a program that generates passwords (
> http://www.ajs.com/~ajs/mkpasswd.html for those who are curious ), and
> was discussing it with someone who asked if it could restrict its
> results to those that alternate sides of the keyboard. This is a
I would point out that a keyboard is not a keyboard. It would appear
that you mean the US QWERTY keyboard. This alternation would not work
for a Dvorak keyboard user or a non-US keyboard user, etc. I suppose
you could keep a hash of keyboards and left-hand/right-hand keys and let
the user select the keyboard.
--
Jason Dufair - jase@dufair.org
http://www.dufair.org/
<xterm> The problem with America is stupidity. I'm not saying there
should be a capital punishment for stupidity, but why don't we just
take the safety labels off of everything and let the problem solve
itself?
------------------------------
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 7557
***************************************