A fancier way to do this is to use grep:my $passwdkey = 'bob'; my $passcount = 0; while (<DATA>) { 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") <DATA>;
-Mark
In reply to Re: Matching values in array
by kvale
in thread Matching values in array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |