On Thursday, Mar 27, 2003, at 11:07 US/Pacific, Luinrandir Hernsen wrote:
How do I run another perl program from within another perl program?
if (x=0) { perl_ program_ 1.pl } else { perl_program_2 } exit;
there are several ways of solving this:
a. perldoc -f system b. perldoc -f open c. perldoc posix { offers access to execl() et al }
I personally am not a fan of the 'backtick' quick fix.
In your illustration you appear not to want to collect any of the responses from this code, but the above three basic methods would help you with those as well. My standard simple solution is
sub run_command { my ($cmd, @arglist) = @_;
open(CMD, "$cmd @arglist 2>&1 |") return("ERROR: $cmd @arglist failed with:$!");
my @response = (); while(<CMD>) { chomp; push(@response, $_); } close(CMD);
[EMAIL PROTECTED]; }
this way I know that if a ref to an array, I got some response, otherwise I got a 'string back' with the error....
YMMV, HTH
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]