in reply to Simple/Quick question about opening creating a file using perl
Create the directory "subfolder" by using mkdir
Check mkdir() for success; if successful, prepend "subfolder" to the filepath to be written; e.g. using File::Spec's catfile