in reply to Creating a new file in a directory
Suggestion:
instead of creating the filename twice, like in
open my $OUT, '>>', "$mycrdir/file_detail.txt" or die "Can't create '$ +mycrdir/file_detail.txt'" ;
it is better do it once and use a variable
my $filename = "$mycrdir/file_detail.txt"; open my $OUT, '>>', $filename or die "Can't create '$filename'";
The reason is to avoid any chance of updating the filename used for open() but forgetting about the error message.
one more improvement - include the reason why the open failed
open my $OUT, '>>', $filename or die "Can't create '$filename': $!";
P.S.: You are using UNIX-Style forward slashes on a Windows-Platform: D:\.../file_detail.txt You probably want to fix that.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Creating a new file in a directory
by RonW (Parson) on Aug 21, 2015 at 19:01 UTC | |
by Monk::Thomas (Friar) on Aug 24, 2015 at 08:15 UTC | |
Re^2: Creating a new file in a directory
by Anonymous Monk on Aug 21, 2015 at 09:19 UTC |