@mainarray=("D:"); sub indexcurrent; indexcurrent("D:"); writefile(); sub indexcurrent { if(opendir(DIR,$_[0])) { local @current=readdir(DIR); for($i=0;$i<=$#current;$i++) { //this if is because the readdir function //returns "." and ".." also as folders if(($current[$i] ne "..")&&($current[$i] ne ".")) { $temp=$current[$i]; $current[$i]="$_[0]\\$temp"; \\Here i append the file name with current folder location push @mainarray,$current[$i]; indexcurrent($current[$i]); } } } } //to write the array of indexed files into a file sub writefile { open(File,">E:\\project\\index.txt"); print File join("\n",@mainarray); close (File); } print "complete"; <>