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.
In reply to Manipulating Arrays by shekarkcb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |