
FishMonger
Veteran
Jan 16, 2012, 7:37 AM
Post #9 of 10
(6140 views)
|
|
Re: [saurabhsharma] Using functions from shell script
[In reply to]
|
Can't Post
|
|
This can be achieved using perl module Shell::Source No it can't. That module allows you to execute a shell script and then import the environment changes that the shell script setup. It does not give the ability for perl to directly execute a shell function, as if it were a perl subroutine, which is what the OP was wanting to achive. Your example code is completely different from what the OP was asking, and in fact, it doesn't even do what you claimed.
You source shell script inside perl script then call the function that lives in shell script. In your example it's the shell wrapper script which is sourcing the script and calling/executing the function, not the perl script. The perl script is simply using its system function to execute a shell script as a child process, which is what we already said it can do.
|