$item = ($input{'item'}); #input passed in from form $found=0; open(FILE, "myfile.txt") || die("$!") #open for reading while() { #while file is open flock(FILE, 2); @line = split(/ /, $_); #split fields with single space $itemDB = $line[0]; #assign 1st element from DB to $itemDB if ($itemDB eq $item) { &Sub1(); #call this sub if true } else { #end if & start else &Sub2(); #call this sub if false } #end else } #end if } #end while flock(FILE, 8); #unlock file close(FILE); #close file (html blah, blah)