From your problem description it's a bit unclear to me whether you mean that you simply want to locate a file relative to the location of your test script, or you mean that the filename string you work with in your script should be expressed as a relative path (e.g. absolute "/path/to/data/test.txt" vs. relative "../data/test.txt"). The former is more common and what Corion's reply is doing - though I would personally recommend using catfile from File::Spec instead of manually concatenating the paths for maximum portability. If you need the latter, which is sometimes useful e.g. when you have to test an API and make sure it handles relative filenames correctly, then you can take the previously mentioned approach and additionally apply abs2rel from File::Spec on the filename.