The short answer is yes, you can create a subdirectory using Perl's mkdir command. Below is a small program that reads the STDIN for a string, and then appends that string to an existing directory. This new directory is passed to the mkdir() command.
- $dest = "C:\\cygwin";
-
while (<STDIN>) {
-
print "Making $dest\\$_\n";
-
chop;
-
mkdir "$dest\\$_";
-
}
-
Two things I noticed while coding up this example: 1) Even though I'm on Windows, I was able to run this code using "/" as the path separator, instead of "\" (which has to be escaped with another "\"). I leave this an exercise for you. 2) The chop() is necessary to remove the trailing newline from my input string. I noticed in the original post the presence of $_, and this could be an issue for you. If in doubt, print the "$_" value using print "[$_]", so you can see if your variable has leading or trailing characters.
Good luck.