in reply to Re: Parsing output with a special format
in thread Parsing output with a special format

I use the `system` commend.
my $test_output = system($cmd);
how can I iterate over it like you did with DATA.
maybe I should use: my @test_output = system($cmd);?

Replies are listed 'Best First'.
Re^3: Parsing output with a special format
by haukex (Archbishop) on Jun 05, 2018 at 08:46 UTC
    my $test_output = system($cmd);

    That won't work, since system returns the exit code and does not capture the command's output. I would recommend capture or capturex from IPC::System::Simple, which can give you an array of lines (my @lines = capture($cmd);). Otherwise, e.g. if the command's output is too large to be captured all at once, you could use a piped open, as I showed here along with other possible solutions.