in reply to return a variable from command line execution to perl

So, how does the child process communicate the "property" and the "key" to the calling process?

If that cmd only sets the value in the environment, you will have to call that .cmd in a way very similar (but different to) Get default login environment.

Maybe the following works as another wrapper .cmd file:

@echo off cd /d %~dp0 call set_prop.cmd db.server.name dbserver set

You would then use the output of that intermediate .cmd file as follows from Perl:

my @output= qx(get_property_values.cmd); chomp @output; print "Got output [$_]" for @output;

Alternatively, see perlipc.

Replies are listed 'Best First'.
Re^2: return a variable from command line execution to perl
by sss (Initiate) on Aug 15, 2014 at 15:04 UTC
    Thank you Corion. I figured out a different way. use backticks and then echo the variable at the end. $dbserv=`call set_prop.cmd db.server.name dbserver & echo %dbserver%` This worked fine.

      If you'd like some nicer error handling for the backticks, see capture from IPC::System::Simple.