On Mon, Apr 7, 2008 at 11:26 AM, Kevin Viel <[EMAIL PROTECTED]> wrote:
snip
>  The results of phymap my be several lines of text.  I would like to process
>  these lines in perl
snip

You have several options the qx// operator*, open**, IPC::Open2***,
and IPC::Open3****.

The qx// operator is the easiest way, but you must wait for the
process to finish and it returns the entire output from STDOUT (which
may be large):

my $output_as_a_string = qx/phymap/;
my @output_as_lines = qx/phymap/;

The open function lets you capture the STDOUT of a process as well,
and it allows you to process the lines one at a time:

open my $fh, "-|", "phymap"
    or die "could not execute phymap: $!";
while (my $line = <$fh>) {
    #do stuff with $line
}

If you need to handle STDIN as well you can use IPC::Open2.  If you
also need to manage STDERR you can use IPC::Open3.

*  http://perldoc.perl.org/perlop.html#qx/STRING/
** http://perldoc.perl.org/functions/open.html
*** http://perldoc.perl.org/IPC/Open2.html
**** http://perldoc.perl.org/IPC/Open3.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to