Hi I trying to create a script for creating a simple folder and subfolder. So basically i am in directory \home\ and want to create folder1, and afterwards subfolder 'folder2'.
so at the end, I am expecting to have a simple \home\folder1\folder2.
This is what I did

#!/usr/bin/perl -w
use File:: Path #i have to put a space between file and path, because if not there will be an emoticon shown on this post :)

#I have only the directory of \home\ and wants to have \folder1 and \folder2
my $path1 = '\home\folder1';
my $path2 = 'folder2' ;


and this error that I get
"\home\folder1" is not exported by the File:: Path module
Can't continueafter import errors at tes.pl line 4

thank you for the guidance

Recommended Answers

All 2 Replies

use File::Path;
my $path1 = '/home/folder1';
my $path2 = 'folder2' ;

mkpath "$path1";
mkpath "$path1/$path2";

Thank you.. What a stupid mistake it was :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.