use v5.16; use strict; use warnings; use open qw(:std :utf8); # Set the default encoding for STDIN, STDOUT & STDERR to UTF-8 use Encode qw( decode ); use IPC::Run3 qw( run3 ); use constant CORECONVERTEREXE => 'C:\Program Files\dBpoweramp\coreconverter.exe'; my $filepath = shift; my @convcmd = ( "${\CORECONVERTEREXE}", "-outfile=nul", "-convert_to=wave", "-errorfile=core.err", qq(-infile=$filepath) ); my $tempoutput1 = decode( 'UTF-16LE', GetCommandOutput(@convcmd) ); print "$tempoutput1\n"; sub GetCommandOutput # (command-string [, params]) { my $stdout = ''; my $stderr = ''; my $exe = $_[0]; print "Command: "; print qq('$_' ) foreach (@_); print "\n"; eval { run3 \@_, \undef, \$stdout, \$stderr }; if ( $@ ) { say "$exe error: $@"; } elsif ( $? ) { say "$exe exited with code $?"; } else { say "$exe completed successfully"; } return $stdout; }