in reply to select elements in a list
First, if you're using pwd like that, you should chomp it. The directory name doesn't end in a newline (normally), but the output of pwd has an extra newline on the end. This would have broken things later had you done something like:my $Current_Dir = `pwd`; print STDOUT "the current directory is $Current_Dir";
as the extra newline would have caused the directory to not be found.open my $output, ">", "$Current_Dir/foo.txt";
Second, you could have used Cwd, which is a core module, and done this much faster and more reliably:
use Cwd; my $Current_Dir = getcwd; print STDOUT "the current directory is $Current_Dir\n";
|
|---|