It should be a comment, but posting the code in the comments really doesn't work, so I do this CW.
Here's how to write this βbetterβ for some meaning better:
#!/usr/bin/perl use strict; use warnings; my $logs_file = 'logspath.txt'; open my $FILE, '<', $logs_file or die "Cannot open '$logs_file': $!"; while ( my $dir = <$FILE> ) { print $dir and chomp $dir; opendir my $dir_h, $dir or die "Cannot open directory '$dir': $!";
In short, use lexical files and directory directories, use the three arguments of the open form and specify the name of the file or directory that you tried to open in the error message enclosed in quotation marks or brackets to see what was actually passed open or opendir .
source share