#!/usr/bin/perl use strict; use warnings; use File::Spec; my $tmpdir = File::Spec->tmpdir(); print "$tmpdir\n"; my $cachedir = File::Spec->catdir($tmpdir, 'host1', 'user1', 'host2', 'user2'); print "$cachedir\n";