Rob Rob - 6 months ago 14
Perl Question

No such file or directory, opening "~/filename" from perl

I am getting the "no such file or directory" error, but of course, there actually is the file in question. I am using double quotes. I am running the code in the directory where the file is located.

Here is my code:

use warnings;
use strict;
use diagnostics;

open(FASTA, "<", "~/LDTest.rtf")

This fails even if:

touch ~/LDTest.rtf
cd ~ run from the shell before starting the script, to ensure that the file exists and is in the current directory.


You have problem in this line:

my $RawSequence = loadSequence("~/LDTest.rtf");

Instead of using tilde give the full path of the file:

my $RawSequence = loadSequence("path/to/LDTest.rtf");

or if you are in the same directory (meaning if you are running your program from the same directory where the file exists), just give the file name:

my $RawSequence = loadSequence("LDTest.rtf");