
Laurent_R
Veteran
/ Moderator
Nov 21, 2017, 1:25 AM
Post #2 of 7
(5942 views)
|
Re: [tester_V] Join files in a directory code errors out
[In reply to]
|
Can't Post
|
|
Hi, does the program print out anything before that error message? If yes, please say so. I don't see any obvious error in your code, but there are things that you could do to improve the error message that you receive and to help diagnosing the problem. Make sure you find the input directory or tell that you can't open it and print out the error returned by the system:
opendir(DH, $dir22) or die "unable to open $dir22 $!"; Further down, print out which file couldn't be opened:
open (my $joined_flow_files_fh,'>',$joined_flow_files) or die "Cannot open file $joined_flow_files $!" ; Again further down, get as much information as possible:
open (my $files22_fh,'<',$files22) or die "Can't open $files22 file from directory $!" ; With these three changes, you should be able to figure out which of these three lines failed and why it failed. Then it should be much easier to find the underlying reason (such as, perhaps, a mistake in the directory name or something else). Just another comment:
foreach my $files22 (@files22) { Having the same name for an array and for its individual items is fairly confusing for you and me (even though the computer should be able to figure out). Also, the loop variable represents only one file at a time, use a singular name, it makes the intent clearer. So, it would be better to have something like this:
foreach my $file (@files22) { (and change $files_22 to $file in the rest of the foreach loop.
|