my $filepath = File::Spec->catfile($folder, $reportfile); open my $reportfile, '>>', $filepath or die "open('$filepath') for appending: $!";