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

Hi All, I have a KSH script, whose method we used to set like . /path/xyz.ksh and then call those method inside the main KSH script like xxxx $a $b $c $d I am now writing a perl script. I need to call the methods xxxx inside the xyz.ksh in my perl script. Can some help me on this. i tried the system and the qx as searched in the google, but they did not work. Please do let me know on what to do. If this cannot be called, is there any alternative method for the same. Thanks in advance. Sam
  • Comment on How to call Shell function or method inside perl

Replies are listed 'Best First'.
Re: How to call Shell function or method inside perl
by choroba (Cardinal) on Mar 23, 2015 at 13:49 UTC
    By method, you probably mean a function. You probably source it (.) to make the function accessible from the current shell. You can call ksh from Perl, which would source the script with the function and run the function:
    $output = qx{ /bin/ksh -c ". /path/xyz.ksh ; xxxx arg1 arg2" }; print $output;
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ