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

I have a function defined in my .profile that is similar to the following:
foo() { print $1 }
I can execute it from the command line just fine...
% foo bar %bar
However if I try and execute it from within Perl...
#!/usr/bin/perl -w $foo=`foo bar`; print $foo;
Here's what I get...
%foo.pl Can't exec "foo": Permission denied at x.pl line 3. Use of uninitialized value in print at x.pl line 4.
I've tried using "system" and "qx" rather than bacticks but to no avail.
Anyone know how to accomplish this?

Replies are listed 'Best First'.
Re: Executing ksh function from within perl script
by nardo (Friar) on Apr 07, 2001 at 03:52 UTC
    $foo = `/bin/ksh -l -c "foo bar"`;