eval { mkpath($dir) }; if ($@) { print "Couldn't create $dir: $@"; } chdir($dir)||die;