use File::Path; eval { mkpath($path) }; if ($@) { print "Couldn't create $path: $@"; }