When perl scripts use relative paths to find files, this path is usually (unless the author did some magic with Cwd or the like) relative to the current working directory, not to the directory in which the script lives.
So probably all you have to do is to create your directory, move the scripts to that dir, but run it from the same directory as before (or chdir to that directory in your wrapper script prior to executing script 1).
I hope I understood what you asked. If not, try to explain a bit more, and tell us what your actual problem is (creating a directory isn't complicated...). | [reply] |
Hi thanks for the quick reply.
I think you know what i want.
This being the case how to i run the script from the same directory as before (when its in "code").
| [reply] |
| [reply] |
Hi smunro16,
I presume that your question is on how to get the path to the scripts.
You have two ways to get it. The first is using $0, that will give you the path to the current perl script, se second is using use Find::Bin.
If you choose to use $0:
my $path=$0;
$path=~s/[^/]+$//;
$path will now have the path to the directory where your perl script is.
Note, however, that if you chdir inside you perl script $0 may not be a valid path to you perl script, once it may be relative to you initial path.
To know more about this you may want to read the thread How do I get the full path to the script executing?.
| [reply] [d/l] [select] |