Use the getcwd function from Cwd, or, even better, use absolute path names.
In reply to Re^3: Problem printing contents of file by Corion in thread Problem printing contents of file by ketaki