I have a perl script that uses relative file paths.
Relative paths apparently refer to the location from which the script is being run, and not to the location of the perl script. How to make my relative paths relative to the location of the script?
For example, I have a directory structure
dataFileToRead.txt ->bin myPerlScript.pl ->output
inside perl script I open the file dataFileToRead.txt using the code my $ rawDataName = "../dataFileToRead.txt"; open INPUT, "<", $ rawDataName;
If I run perl script from bin directory, it works fine
If I run it from the parent directory, it will not be able to open the data file.
source share