This is cross posted from perlmonks
(http://perlmonks.org/?node_id=1060079). The end goal is to echo an
array of iptables save data into iptables-restore. I am getting output
via IPC::Cmd but not via the redirect (which is fine) however, the
pipe also doesn't seem to be working. Any ideas?

#!/usr/bin/env perl

use strict;
use warnings;

use Data::Dumper;
use IPC::Cmd qw/run/;

my @in = ("Test foo", "Test bar");

print "In: " . Dumper(@in);

@in = ("Test foo", "Test bar");

my @out = run(command => [echo => -n => @in] , '|', [ sed => -r => "s/
+(foo|bar)/pass/" ], '>', \my $out);

print "Out: " . Dumper(@out);
print "Redir: " . Dumper($out);


#### Out:

 % ./t2.pl
In: $VAR1 = 'Test foo';
$VAR2 = 'Test bar';
Out: $VAR1 = 1;
$VAR2 = undef;
$VAR3 = [
          'Test foo Test bar'
        ];
$VAR4 = [
          'Test foo Test bar'
        ];
$VAR5 = [];
Redir: $VAR1 = undef;

-- 
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