in reply to Create file in a specified directory

Print out $! to see the error message:

open $fh, ">$uniqueCaptureName" or die "can't open file: $!\n";

Better yet, use the three arg open:

open $fh, '>', $uniqueCaptureName" or die "can't open file: $!\n";

Replies are listed 'Best First'.
Re^2: Create file in a specified directory
by ramya2005 (Scribe) on Sep 01, 2005 at 18:47 UTC
    Thank you. The code was failing because I didn't have the directory named 'Input' under the 'Public'. When I created that directory it worked

    Is there a way to check the directory structure and create directories as specified in the path if it doesn't exist already?
      use -d (perldoc -f -X) to check for exsistence.. for making a directory there's perldoc -f mkdir, and for making it recursively there's mkpath in File::Path

      yes , sure you can check for that

      #check if the $dir does not exits then we create it if(!-d $dir){ mkdir($dir);}
      HTH