#!/usr/bin/perl use strict; use warnings; use File::Spec::Functions qw(splitpath catdir rel2abs); # mkdir -p emulator, call with this.pl /path/to/create my $path = rel2abs(shift @ARGV); my $place = ''; foreach my $dir ( splitpath($path) ) { $place = catdir($place, $dir); (-d $place) || (mkdir $place, 0755) or die "Problem making $place: $!"; }