Reading output from command into Perl array -


i want output of command array — this:

my @output = `$cmd`; 

but seems output command not go @output array.

any idea go?

this simple script works me:

#!/usr/bin/env perl use strict; use warnings;  $cmd = "ls";     @output = `$cmd`;     chomp @output;  foreach $line (@output) {     print "<<$line>>\n"; } 

it produced output (except triple dots):

$ perl xx.pl <<args>> <<args.c>> <<args.dsym>> <<atob.c>> <<bp.pl>> ... <<schwartz.pl>> <<timer.c>> <<timer.h>> <<utf8reader.c>> <<xx.pl>> $ 

the output of command split on line boundaries (by default, in list context). chomp deletes newlines in array elements.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -