The [doc://mkdir] function creates directories (which I assume are what you mean by "subfolders"). The [doc://open] function can open files even if you prepend a path to them. If you want to create multiple directories in one go, have a look at [cpan://File::Path].
use strict;
use warnings;
my $outdir = "output";
if (! -d $outdir) {
warn "Creating '$outdir'";
mkdir $outdir
or die "Couldn't create '$outdir': $!";
};
my $outname = "$outdir/test.txt";
open my $outfile, ">", $outname
or die "Couldn't create '$outname' : $!";
print $outfile, "Hello World\n";
If you want to create multiple directories in one go, have a look at File::Path.Corion is not saying it with so many words, but he is talking about the function mkpath(), in File::Path, which comes with Perl.
perlmonks.org content © perlmonks.org and bart, Corion, kgraff, murugu, tamaguchi
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03