PDA

View Full Version : Perl Program to create folder structue


sanjeevappa
08-19-2005, 02:40 PM
Hi,

As new to perl iam not getting how to write a perl program to create folder structure.

For this i have a input text file, containing content like this :

A,B
A,C
B,X
B,Y
C,M
C,N
X,P
X,Q

By reading this file i have to write a perlprogram in such a way that :

A should be top folder, in that B & C subfoldrs .
In folder B, X & Y folders should be creatd.
Inside C, M & N folders.

Like that in X P & Q folders, the input file may contain any number of folders.

After Searching i got one perl Function somethink mkfolder(....) it takes possible paths.

For this i have to read the input file make things like below.

A/B/X/P
A/B/X/Q
A/B/Y
A/C/M
A/C/N

These paths if i pass to that function it will automatically create folder structure.

If any one give program for this it will help a lot.

Thanking in advance,
San.

gsoft
08-19-2005, 05:29 PM
Looks like homework to me.

Anyway the program would be a little difficuilt you will need to know where each folder is already located for it to work. At a first glance I thought it would be relatively simple but since its two to a line and b needs to be within a you would need something to store the already created directories into then check if its already created if so goto that position and create another.

Now since I think its homework Im not going to give a solution and I doubt anyone else would you should read the FAQs why.

FishMonger
08-19-2005, 05:31 PM
This sounds like a homework assignment. We can't just give you the answer but if you post your code and ask a specific question about the portion that you're having trouble with, we will be able to provide some guidance.

sanjeevappa
08-22-2005, 10:50 AM
Hi,

Really iam not getting your responses "It looks like a Home Work".

FishMonger
08-22-2005, 11:45 PM
Based on the type of script you're needing and the wording of your question, it appears to be a programing assignment from a course that you're taking. If that's the case, it's against the rules to provide direct answers especially when you're asking for us to provide you with a complete script.If any one give program for this it will help a lot.If this is not for a course, then we still need/want you to help by first writting some of the code yourself and post it with direct questions on the parts that are giving you trouble.