use strict; use warnings; use Capture::Tiny qw( capture_merged ); my $input = shift; my $output = '/home/me/output.txt'; my $run = '/home/me/ipinfo.pl'; open my $infh, '<', $input or die $!; open my $ofh, '>', $output or die $!; while( <$infh> ) { chomp; my( $captured, @results ) = capture_merged { system $run, $_ }; print $ofh $captured; } close $ofh or die $!; close $infh;