Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, How can i invoke a ksh program from perl script, wherein the unix program expects some input parameters. Kindly help me

Replies are listed 'Best First'.
Re: Invoke unix program from perl program
by jethro (Monsignor) on Jan 08, 2010 at 10:30 UTC

    Just put the parameters behind the call:

    system("program.sh $param1 4 $param2");

    or, if you want to get the output of the program into your perl script:

    my @result= `program.sh $param1 4 $param2`; #backticks or open($f,'-|',"program.sh $param1 4 $param2"); while (my $result= <$f>) { ...
      I prefer to call
      system "program.sh", $param1, 4, $param2;
      unless I really want to shell to interpret any special characters.
Re: Invoke unix program from perl program
by Ratazong (Monsignor) on Jan 08, 2010 at 10:26 UTC

       $result = system("program param1 param2");

    Update: result-type changed to scalar (thanks jethro)