1. Perl
  2. builtin functions
  3. here

mkdir function - create a directory

You can use the mkdir function to create a directory. If it succeeds, it returns true, and if it fails, it returns false. Be sure to check the return value. If unsuccessful, the error content is set to $!.

$ret = mkdir $dir

Example

This is an example to create a directory using the mkdir function.

use strict;
use warnings;

# Create a directory.
# mkdir $dir
print "1: Create a directory.\n";
my $dir = "dir_20080523_ $$";
mkdir $dir
  or die "Unable to create $dir.:$!";
print "$dir has been created.\n";

Related Informatrion