Skip to content

Instantly share code, notes, and snippets.

@jflopezfernandez
Created November 21, 2018 19:43
Show Gist options
  • Save jflopezfernandez/c19d7ec5ae6af493e971221db74cf426 to your computer and use it in GitHub Desktop.
Save jflopezfernandez/c19d7ec5ae6af493e971221db74cf426 to your computer and use it in GitHub Desktop.
#! /usr/bin/perl
# Uses file existence operator to test whether specified directory already exists.
# Directory name input mechanism is not assumed; trivial example provided.
#
# Author: Jose Fernando Lopez Fernandez
# Date: 21-November-2018
#
# Note: "say" function requires "use v5.10" or higher
my $newDirectoryName = "New-Directory";
if (-e $newDirectoryName) {
say "[Error]: Directory Already Exists.";
} else {
say "Creating new directory: $newDirectoryName";
my $status = mkdir($newDirectoryName);
say "[Status]: $status";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment