#!/usr/bin/perl use strict; use warnings; use File::Spec; my $path = File::Spec->catdir('C:','Temp'); mkdir($path); my $file = File::Spec->catfile($path,'index.html'); open( my $fh,'>',$file) or die $!; #... close $fh;