Search code examples
perlstdoutstdinfilepath

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";
close OKBLABLA;

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


Solution

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