in reply to Re: Redirecting OUTPUT of system($command) to an array
in thread Redirecting OUTPUT of system($command) to an array

Nkuvu,
I would guess that this is 1 step short of being what is desired ultimately. The output likely needs to be split (by either horizontal or vertical whitespace).
my $command = "/usr/local/some/command"; my $result = `$command`; my @array = split /\n/ , $result;
Otherwise the entire result ends up in slot 0 of the array you will have no control over how the output is stored into the array.

Cheers - L~R

Update: If the desired outcome is to split on newlines, then there is no need to store the result into a temporary scalar and split yourself as japhy points out below.

Replies are listed 'Best First'.
Re: Re: Re: Redirecting OUTPUT of system($command) to an array
by japhy (Canon) on May 13, 2004 at 18:38 UTC
    Except that readpipe() (which is what implements `...` and qx()) returns a list of lines in list context. So an array on the left-hand side is fine.
    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
Re^3: Redirecting OUTPUT of system($command) to an array
by Nkuvu (Priest) on May 13, 2004 at 19:23 UTC

    Thanks for the caveat, I'll keep that in mind. So far, every time I've resorted to using backticks, the system command I've been executing has output multiple lines of information.