use File::Spec; my $path = File::Spec->catfile("C:", "Dir1", "Dir2", "Dir3", "KeepMe"); my $base = File::Spec->catdir("C:", "Dir1", "Dir2", "Dir3"); # or my $base = File::Spec->catdir("C:", "Dir1", "Dir2", "Dir3"); my $path = File::Spec->catfile($base, "KeepMe");