use warnings; use strict; use IPC::Run3; use Encode qw/decode/; my @outputs; for my $loc ('/sys/general', '/env/bat', '/env/ps') { run3 ['uemcli','-d',$vnxe_ip,'-u',$username,'-p',$password, $loc,'show','-detail'], undef, \my $out; my $str = decode('UTF-16', $out, Encode::FB_CROAK); push @outputs, $str; } print $outputs[0], "\n"; open my $fh, '>', $textfile or die "$textfile: $!"; print $fh $outputs[1]; close $fh;