Hi All,

I have a simple problem, hope monks will give me a solution.Problem is like this.I have some lines in a file. They are all dir paths.I should iterate through each and if i found a file say *END*.txt inside that dir, i should delete the entry in that file, if not continue to find, I have used Arrays for this. But my code is giving infinite loop. Please help me out of this.

open(FD,"FILE_LAST_MOD_DIR") or die $!; my @array_LAST_MOD_FILE=<FF>; close(FD); #While length of array not eq 0 while(@array_LAST_MOD_FILE != 0) { for($arr=0;$arr<@array_LAST_MOD_FILE;$arr++) { chomp($array_LAST_MOD_FILE[$arr]); print "ARRAY ELEMENT in $arr position |$array_LAST_MOD +_FILE[$arr]| \n"; my @arr_find=`find $array_LAST_MOD_FILE[$arr] -iname * +END*.txt -type f`; my $length_of_array=@arr_find; print "LENGTH OF THE ARRAY=$length_of_array|\n"; #If Length is 0 means, file not yet created, go to next path if($length_of_array eq 0) { next; } else { #You got END file, delete the entry from FILE as well as A +rray delete $array_LAST_MOD_FILE[$arr]; open(FD,">>FILE_LAT_MOD_DIR") or die $!; foreach my $i (@array_LAST_MOD_FILE) { print FD"$i\n"; } close(FD); }#End If }#End For }#End While

Please let me know where i am doing mistake.

Thanks,
ShekarKCB.

In reply to Manipulating Arrays by shekarkcb

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.