Hello Monks,
i have written a recursive based directory indexing program which indexes all folders,subfolders and files(specifically for "D"). the problem is the program completes abruptly after a certain depth of folders.i cannot observe any specific point at which it stops.in D containing over 30000files and folders the program runs only upto 1000 files without any error being thrown. i have to make it clear that no errors are produced during execution of program
@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"; <>
1.The writefile function displays over 1000 files instead of over 30000
2.I use push so that i can keep the current location and it does not matter whether i write the file in the beginning or the end as i can see the same progress.
3.Also i actually need to use mainarray to make a file search.that is why i use push.
This program has been also written in C++(dev) and has been compiled.It runs indexing the whole directory. I have used the same conditions and variables. I started it out as a perl program,then to find out the reason why it didnt work i tried it in c++. please help

In reply to File Indexing program by chetanspecial

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.