Can't open directory, or what's wrong with my (Perl) code?

opendir, perl

Solution

`chomp` has no meaningful return value that you can then pass onto `opendir`. You need to `chomp` your string in a separate statement, above the `opendir`.

 chomp;
 opendir DIR, $_ or die ...

Problem

I have a file name `logspath.txt` which contain on the logs directory path on the machine. one directory each line. Although the directory exist, Perl say it doesn't. ``` #!/usr/bin/perl -w open FILE,"logspath.txt" or die $!; while (<FILE>){ print $_; opendir ($DIR,chomp($_)) or die $!; ``` When I'm running the script I get: ``` /home/amosa/ No such file or directory at archive.pl line 6, <FILE> line 1. ``` Listing the directory : ``` ~$ ls -l /home/amosa/ total 6 drwxr-xr-x 11 amosa prodapp 1024 Mar 2 12:49 deploy drwxr-xr-x 2 amosa prodapp 512 Mar 2 12:39 lib -rw-r--r-- 1 amosa prodapp 787 Mar 2 11:02 s ``` Any advice?

Original source