On 4/5/11 Tue  Apr 5, 2011  7:11 AM, "Chap Harrison" <c...@pobox.com>
scribbled:

> On Apr 5, 2011, at 8:49 AM, Shawn H Corey wrote:
> 
>> 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__
> 
> Is there any reason not to just use qx?

For short programs with small amounts of output qx and backticks are fine.
For longer executing programs or those with lots of output, you might want
to use open because that way you can get the output lines from the program
as they are generated, rather than waiting until the program has completed.




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to