I am trying to read folder and subfolder and print their name into a text file.I am able to read the folder and its content and write it to the textfile but I am not able to read the content of the subfolder and write its content..FOR Eg : I have
folder1\text1
folder1\text2
folder1\folder2 \text3
I am reading folder1 and it is writing text1,text2 and folder2 in another textfile.I need to print the total structure of the subfolder ..like folder2\text3.. not just folder2.my code is as following
[code=perl]
#!C:\home\bin\p erl -w
open (MyHandle,">C\: \\ravi\\ravilis t.txt") or die("File Open Error");
opendir MYDIR, "C\:\\folde r1";
@contents = grep !/^\.\.?$/, readdir MYDIR;
closedir MYDIR;
foreach $listitem ( @contents )
{
print MyHandle $listitem;
print MyHandle "\n";
}
[/code]
folder1\text1
folder1\text2
folder1\folder2 \text3
I am reading folder1 and it is writing text1,text2 and folder2 in another textfile.I need to print the total structure of the subfolder ..like folder2\text3.. not just folder2.my code is as following
[code=perl]
#!C:\home\bin\p erl -w
open (MyHandle,">C\: \\ravi\\ravilis t.txt") or die("File Open Error");
opendir MYDIR, "C\:\\folde r1";
@contents = grep !/^\.\.?$/, readdir MYDIR;
closedir MYDIR;
foreach $listitem ( @contents )
{
print MyHandle $listitem;
print MyHandle "\n";
}
[/code]
Comment