No such thing as a small change | |
PerlMonks |
using "require" problemby gauss76 (Scribe) |
on Sep 26, 2017 at 07:51 UTC ( [id://1200087]=perlquestion: print w/replies, xml ) | Need Help?? |
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
Back to
Seekers of Perl Wisdom
|
|