Of course, a loop would be a bit more elegant, here's just one example.
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;
Update: Note that both prints in this example assume you don't have any Unicode (non-ASCII) characters in the strings (as your sample data shows). If you did, you'd need to set an encoding on the filehandles you're writing the data to - that's STDOUT, with for example use open qw/:std :utf8/; or several variations on that, and for filehandles, for example open my $fh, '>:encoding(UTF-8)', $filename or die "$filename: $!";.
In reply to Re^5: Unicode issues with emc uemcli
by haukex
in thread Unicode issues with emc uemcli
by pritesh_ugrankar
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |