I would like to have the files that I am creating to be output into the directory I created in my perl script.
I can create the directory
use File::Path;
$dir = "foo/";
mkpath($dir);
and my files
$FILE = "output.txt";
unless(open $filehandle, ">", $FILE){
die "\nUnable to create $FILE:\n$!";
}
printf $filehandle "writing stuff to my file\n";
printf $filehandle "and some more stuff\n";
close($filehandle);
Everything works fine except I was the files to be output into the directory I made earlier in the script.
Any help would be appreciated.
This code will do what you’re asking:
You need to specify the path where you want your file to be written. You could use either an absolute path or a relative path, starting from your current working directory.