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

Dear Masters,
I have the following directory structure for storing my code and one binary executable use by the Perl's code.
~/MyPerl | | |__ src/ |_ mycode.pl | |_ a_program.out
Currently in mycode.pl, I have
use strict; use warnings; my @output = `./a_program.out -f someparam`; # line 217 # This also does not work # my @output = `home/myname/MyPerl/src/a_program.out -f someparam`; chomp @output; # do something with @output # Rest of the code
Although I have no problem running the following:
~/MyPerl $ perl -c src/mycode.pl mycode.pl syntax OK
But I have problem when doing this:
~/MyPerl $ perl src/mycode.pl
It gives:
Can't exec "./a_program.out": No such file or directory at src/mycode.pl line 217.
I've tried setting full path under backtick also but it still give the same error. What's wrong with my path setting under backtick? Did I miss anything?

Update: Thanks a lot for the answer. It works fine now.

---
neversaint and everlastingly indebted.......

Replies are listed 'Best First'.
Re: Backtick and problem with setting path within it
by ikegami (Patriarch) on Jun 04, 2006 at 05:28 UTC

    We covered this in your last post.
    home/myname/MyPerl/src/a_program.out
    is not the same as
    /home/myname/MyPerl/src/a_program.out
    You want the latter.

    src/a_program.out
    would also work since your work directory is
    /home/myname/MyPerl
    Relative paths (paths that don't start with "/" or "~") are relative to the working directory, which can be different than the directory in which the script resides.