thanks for the answer, but my problem is not to run a command. The question is if I have a function "foo" implemented on shell script. And I want to call foo on my perl program, is it possible to do it?

Either design your shell script to execute the function and have Perl execute that shell script or IMO a better solution would be to write a Perl subroutine that accomplishes the same thing as the shell function.

The only "foreign" programming language, where function can be linked to Perl, is C.

As far I understand, the parrot project allows possibly a (Parrot-)Perl-Program to be linked to a program in another language, but I doubt that we will ever see a Parrot-Implementation of bash, zsh, ksh (or whatever shell language you are using).

I have also done a work around for this problem. Lets say if you want to call a function written inside a shell script (first.sh) from a perl script, you can write a wrapper shell script to achieve the same.

e.g. there is a function fun1() in (first.sh) which you want to call from a perl script (myperltest.pl)

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.

Quote

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.