views:

115

answers:

1

Is there a way I can open a new cmd window and pass a variable and once completed close that window?

I have found some info but not enough that I can get it to work.

system('start "List Perl files" dir c:/dfd/dfdf.pl /B');

Opens window but does not run script.

+2  A: 

Main script:

my ($x, $y) = (888, 999);
system('start', 'List Perl files', 'perl', 'other_script.pl', $x, $y);

The other script:

print "Args received = @ARGV\n";
<STDIN>;

BTW, there's probably a better way to achieve your larger goals -- for example, organizing the needed functionality into modules. Passing information from one script to another via command-line arguments and @ARGV can be a hassle and a limiting factor.

FM
I think that is ok but it closes the window as soon as it opens it...
Phil Jackson
was an error on page, cheers!
Phil Jackson
how do I retrieve an array of vars... `foreach( @ARGV ) { print @_ . "\n";}<STDIN>;` ??
Phil Jackson
You can have problems with quotes in single argument `system`. Better use `system("start", "List Perl files", "perl", "other_script.pl", $x, $y);`.
Ivan Nevostruev
@Phil See example of perl array loops in manual - http://perldoc.perl.org/perlsyn.html#Foreach-Loops
Ivan Nevostruev