RE: Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
> Suggestion: rather than use egrep (which, as Chas points out, requires > a new process - and ignoring his solution for a moment - sorry), it > might make more sense (and increase portability) to move the RegEx > parsing into Perl. > > my $var = grep {/This|That/}, `cmd --arg1 --arg2; > (Did I do

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:50 PM, yitzle <[EMAIL PROTECTED]> wrote: snip > my $var = grep {/This|That/}, `cmd --arg1 --arg2; > (Did I do this right? I'm not very familiar with grep) snip That is mostly correct. You are using the grep function in scalar context, so it will return the number of it

Re: Suppressing output from backtick operator

2008-02-20 Thread yitzle
Suggestion: rather than use egrep (which, as Chas points out, requires a new process - and ignoring his solution for a moment - sorry), it might make more sense (and increase portability) to move the RegEx parsing into Perl. my $var = grep {/This|That/}, `cmd --arg1 --arg2; (Did I do this right? I

RE: Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
> That should be "one process" not "on process". It is important, and I > forgot to add this, to use waitpid* to reap the child process after an > open3 unless you don't mind zombies. > > * http://perldoc.perl.org/functions/waitpid.html Thank you Chas and yitzle jlc -- To unsubscribe, e-mail: [

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:42 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > This code also benefits from the fact that it only spawns on process snip That should be "one process" not "on process". It is important, and I forgot to add this, to use waitpid* to reap the child process after an op

Re: Suppressing output from backtick operator

2008-02-20 Thread yitzle
On both Windows and Unix, there are two output streams, STDOUT and STDERR. The backtick operator captures the STDOUT and lets you use it eg to set $var. STDERR is what you are seeing. (Perl's warn prints to STDERR) What you can do (on Linux machine) is redirect the STDERR to null. I don't think egr

Re: Suppressing output from backtick operator

2008-02-20 Thread Chas. Owens
On Wed, Feb 20, 2008 at 5:18 PM, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > How does one do this? I have the output in a script set to a variable such as: > my $var = `cmd --arg1 --arg2 | egrep 'This|That'` and I don't want to see it > as the script is run. snip Supressing output on STDERR fr

Suppressing output from backtick operator

2008-02-20 Thread Joseph L. Casale
How does one do this? I have the output in a script set to a variable such as: my $var = `cmd --arg1 --arg2 | egrep 'This|That'` and I don't want to see it as the script is run. Thank you, jlc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://