chdir "$results$filepath" or print "cannot chdir to $results$filepath ! $!"; if (-e "test.txt") { open (my $test, '<', "test.txt") or print "Can't open file: $!"; while(my $line = <$test>){ chomp $line; split(" ", $line); print $line; } }