Reputation: 780
Say, I have a shell script like this:
function getDir
{
echo "DirName"
}
I want to use that function from a Perl script:
`source utils.sh`;
my $dir_name = `getDir`;
print $dir_name;
But this is not working. How I can get this done? Essentially I need to get the return value from a shell function to a Perl script.
Upvotes: 2
Views: 2848
Reputation: 206859
You'll need to call that function in the same shell that sources utils.sh
, so:
my $dir_name = `source utils.sh; getDir`;
chomp($dir_name);
print $dir_name, "\n";
Upvotes: 9