use Cwd 'chdir'; chdir "../htdocs/"; open (FILE, "<$ENV{'PWD'}info.txt") || print "There is no file here in $ENV{'PWD'}info.txt"; while ( my $line = ) { chomp($line); #code.... }