if($lT && $Title ne "*") { for($index=0;$index<@tit;$index++) { $wrd=$tit[$index]; print "$index,$wrd\n"; COMMENT - to make sure each word was processed individually. Works. `grep -i \"$wrd\" $DataIn > $DataTmp`; COMMENT - I am assuming that the GREP results from DataIn are copied into DataTmp $DataIn=$DataTmp; COMMENT - here the files are swapped I guess. if($DataTmp eq $DataTmpa){$DataTmp=$DataTmpb;print "tempb\n";} # if else{$DataTmp=$DataTmpa;print "tempa\n";} # else } # for } # if $IT