my $passwdkey = 'bob'; my $passcount = 0; while () { chomp; if ($_ eq $passwdkey) { $passcount++; print "ok\n"; } } print "final '$passwdkey' count = $passcount\n"; __DATA__ ted bob carol alice bob hank #### my $passcount = grep {$_ eq "$passwdkey\n") ;