[thelist] Call exe program on win32 using perl

Erik Michael Sabowski sabowski at wam.umd.edu
Thu Jul 27 23:39:11 CDT 2000


yep, using backticks works too. i thought his situation called for
system instead of backticks, but since i didn't actually ask him, i
could have been wrong :) anyway, here's a tip that tells you when you
use what method:

#airyk

<tip type="perl" author="#airyk">

deciding which method of calling an external program depends of what you
are going to do with the output of the program. If you don't need to
pull the output of the external program into your script, use 'system.'
If you want to save the output of the external program into a variable,
use the backticks: $var = `program args`

don't use the backticks in a void context...use 'system' instead

also, there is the 'exec' function, which will terminate the current
script and start another program in it's place.

there is also 'fork' and 'exec', but their use is generally for advanced
perl programmers, and the win32 version of perl may not even have those
functions implemented
</tip>

Michael Percy wrote:
> 
> I prefer to do:
> 
> `someprogram.exe arg1 arg2`; or
> `someprogram.exe $arg1 $arg2`; or
> $output = `someprogram.exe $arg1 $arg2`;
> 
> etc...
> 
> Mike
> 

-- 
Erik M. Sabowski
sabowski at wam.umd.edu

"i don't like being quoted."




More information about the thelist mailing list