dellnak has asked for the wisdom of the Perl Monks concerning the following question:
Here's the deal:
I have many perl scripts I want to run in a specific order and this is accomplished by using a main (perl) script calling system() for every one of the scripts. Many of these scripts contain require()s or other kind of references to files and they are made using relative paths (../bar instead of /the/whole/directory/structure/bar). However, when calling such scripts from a main script instead of running them on their own, the relative paths won't work. I guess this is the same phenomenon as calling the script manually from a directory other than it's own.
Is there a way of fixing or avoiding the problem, other than changing every file path to an absolute one? I'm hoping there is something like system(./dir/foo.pl, BEHAVE_AS_IF_THE_SCRIPT_WAS_CALLED_FROM_ITS_OWN_DIR)
Any possible help is appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: system("./foo.pl") and a problem with relative paths in foo.pl
by roboticus (Chancellor) on Nov 20, 2009 at 13:32 UTC | |
by dellnak (Initiate) on Nov 20, 2009 at 14:07 UTC | |
|
Re: system("./foo.pl") and a problem with relative paths in foo.pl
by cdarke (Prior) on Nov 20, 2009 at 13:27 UTC | |
|
Re: system("./foo.pl") and a problem with relative paths in foo.pl
by MidLifeXis (Monsignor) on Nov 20, 2009 at 16:21 UTC |