use File::Basename qw(dirname); my $script_dir = dirname($0); my $path = "$script_dir/Pandoras Box/$file.txt"; ... #### chomp(my $file =uc()); my $path = "./Pandoras Box/$file.txt"; open FILE, '>>', $path or die "unable to append to $path: $!"; ... #### my $path = "Pandoras Box/$file.txt"; ...