note
AnomalousMonk
<blockquote><i>
WHats wrong in here, why can this file handle not open ?
</I></BLOCKQUOTE>
<p>
It's good that you are checking the success of the [doc://open] function call and calling [doc://die] if it fails. The answer to the question "why?" is contained in the <c> $! </C> error variable (see [doc://perlvar], especially the discussion in [doc://perlvar#Error-Variables]). Put that in your <c>die</C> function and see the result: <br>
<c> open(WRITEFILE, ">$filelist") || die("ERROR: unable to open file: $! \n");</c> <br>
</P>
<p>
In addition, the statement <br>
<c> my @files = (file1, file2, file3);</c> <br>
suggests you are not using [doc://warnings] and [doc://strict] at the beginning of your code: <br>
<c> use warnings;</c> <br>
<c> use strict;</c> <br>
I strongly suggest you do so.
</P>
<p>
Furthermore, the statement <br>
<c> $filelist = "C:\Users\cign\Desktop\printFile.txt";</c> <br>
is highly suspect. Add a [doc://print] statement for <c> $filelist </C> immediately after this assignment and check if what is printed is what you expect. The other tactic is to include the filename in delimiters in the [doc://die] call discussed above: <br>
<c> open(WRITEFILE, ">$filelist") || die("opening '$filelist': $!\n");</c> <br>
</P>
<p>
The next step is to use the three-argument form of <c>open</C>: <br>
<c> open my $writefile, '>', $filelist or die "opening '$filelist': $!"</c> <br>
</P>
1022709
1022723