use v5.16; use strict; use warnings; use open qw(:std :utf8); # Set the default encoding for STDIN, STDOUT & STDERR to UTF-8 use IPC::Run3 qw( run3 ); my $filepath = shift; my @extractcmd1 = qw( sacd_extract.exe ); my @tempoutput1 = GetCommandOutput( @extractcmd1 ); my @extractcmd2 = qw( sacd_extract.exe --print --export-cue ); my @tempoutput2 = GetCommandOutput( @extractcmd2, qq(input=$filepath) ); open( my $fh, ">:raw", "run3.txt" ); print( $fh "~~~$_" ) foreach (@tempoutput2); 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 ( $? & 0x7F ) { say "$exe killed by signal ".( $? & 0x7F ); } elsif ( $? >> 8 ) { say "$exe exited with error ".( $? >> 8 ); } else { say "$exe completed successfully"; } say "stdout=$stdout"; say "stderr=$stderr"; return map { chomp; $_ } split(/\n/, $stdout); } #### D:\test>perl -S test-run3.pl "E:\Temp\Greatest Hits.iso" Command: 'sacd_extract.exe' sacd_extract.exe completed successfully stdout= stderr=No such file or directory libsacdread: Can't stat /dev/cdrom Command: 'sacd_extract.exe' '--print' '--export-cue' 'input=E:\Temp\Greatest Hits.iso' sacd_extract.exe completed successfully stdout= stderr=No such file or directory libsacdread: Can't stat /dev/cdrom #### 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; } #### D:\test>perl -S test-run3conv.pl "E:\Temp\Greatest Hits.iso" Command: 'C:\Program Files\dBpoweramp\coreconverter.exe' '-outfile=nul' '-convert_to=wave' '-errorfile=core.err' '-infile=E:\Temp\Greatest Hits.iso' C:\Program Files\dBpoweramp\coreconverter.exe exited with code 256 dBpoweramp Music Converter (C) 2021 Illustrate Ltd Encoding: wave" Audio Source: E:\Temp\Greatest Audio Destination: nul" 0%-----------25%-----------50%-----------75%-----------100%