thank you all!
Anjan

On Tue, Apr 5, 2011 at 9:49 AM, Shawn H Corey <shawnhco...@gmail.com> wrote:

> On 11-04-05 09:24 AM, ANJAN PURKAYASTHA wrote:
>
>> Hi,
>> Is there any way to run a shell command from within a perl script and
>> capture the output in, say, an array?
>> One can run a shell command through the system function. But system itself
>> just returns a status code.
>>
>>
> You could use open:
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
>
> open my $ls_fh, '-|', 'ls' or die "could not open `ls`: $!\n";
> chomp( my @files = <$ls_fh> );
> close $ls_fh or die "could not open `ls`: $!\n";
>
> print "@files\n";
> __END__
>
>
> --
> Just my 0.00000002 million dollars worth,
>  Shawn
>
> Confusion is the first step of understanding.
>
> Programming is as much about organization and communication
> as it is about coding.
>
> The secret to great software:  Fail early & often.
>
> Eliminate software piracy:  use only FLOSS.
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
===================================
Anjan Purkayastha, PhD
Senior Computational Biologist
TessArae LLC
46090 Lake Center Plaza, Suite 304
Potomac Falls, VA 20165**
Office- 703.444.7188 ext. 116
Mobile-703.740.6939
===================================

Reply via email to