in reply to Re^2: execute vbscript code inline in Perl script
in thread execute vbscript code inline in Perl script

To pick up on what NetWallah wrote, personally I usually recommend using a module instead of Perl's builtins like qx// because modules will give you more features and better error handling. In this case, I might suggest IPC::System::Simple's systemx and capturex (the only downside in this case is that STDERR can't be captured, but it doesn't look to me like you need that, although I could be wrong). If you are worried about where the script files might be written, or that they might get overwritten, you could use temporary files (which will have unique names) via the core module File::Temp, like this:

use warnings; use strict; use File::Temp qw/tempfile/; use IPC::System::Simple qw/capturex/; my ($tfh,$tfn) = tempfile( SUFFIX=>'.vbs', UNLINK=>1 ); print $tfh <<'END_VBS'; Dim num1, num2, final num1 = 30 num2 = 50 final = num1*num2 WScript.Echo(final) END_VBS close $tfh; print "running $tfn\n"; # Debug my $final = capturex('cscript','//nologo',$tfn); chomp($final); print "final: '$final'\n";

(not fully tested because I'm not on Windows at the moment)

To have the scripts created in a specific directory, you can use tempfile( ..., DIR=>"C:\\Some\\Path" ). The UNLINK option causes the temporary file to be deleted when the script ends.