gauss76 has asked for the wisdom of the Perl Monks concerning the following question:
Hi All
I have the following problem and don't know how to resolve it.
Basically, I have a perl .pl file (main.pl) that requires another .pl file (routines.pl) in order to work correctly (everything running on a Linux machine). The files are both in the same folder and I currently use the following syntax in the file main.pl
require "./routines.pl";This works fine if I run main.pl from the folder that contians the two files. However if I run the program from a different folder with, say, the command
perl /home/user/code/main.plThen I get an error saying "can't locate ./routines.pl.
I know that I can change the "require" statement to:
require "/home/user/code/routines.pl"However, for me, this is not an option as I need to copy the code to another Linux system where the containing folder will be different (the two files will still be in the same folder)
So, my question: Is there any way to use the same "require" statement so that I can run my program from any folder with the command
perl /home/user/code/main.plwhere the folder for the code (/home/user/code/main.pl) can change?
Please let me know if anything is not clear.
Many thanks for any help on this
gauss76
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using "require" problem
by haukex (Archbishop) on Sep 26, 2017 at 07:54 UTC | |
|
Re: using "require" problem
by Discipulus (Canon) on Sep 26, 2017 at 07:58 UTC | |
by haukex (Archbishop) on Sep 26, 2017 at 08:03 UTC | |
|
Re: using "require" problem
by hippo (Archbishop) on Sep 26, 2017 at 08:01 UTC | |
|
Re: using "require" problem
by Anonymous Monk on Sep 26, 2017 at 13:07 UTC | |
by haukex (Archbishop) on Sep 26, 2017 at 13:24 UTC |