Zesa Rex Zesa Rex - 9 months ago 36
Perl Question

Why am I causing the "or die" when trying to open Filehandle?

Does anyone see the problem here?

use FindBin '$Bin';

$scriptdir = $Bin;
$folder= "64521459";
$file = "201608291350_60002015_1_Log-Minim.csv";

print "$scriptdir\\OK\\$folder\\$file";
open (OKBLABLA, ">", "$scriptdir\\OK\\$folder\\$file") or die "Can't create OK folder";
print OKBLABLA "success";

It seems like the
part is causing problems; when I remove it, it works - any idea why? Won't the script create a fresh directory by itself?


No, open cannot create a nonexistent directory, on any platform, in any language I know.