in reply to Matching values in array
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Matching values in array
by Anonymous Monk on Mar 02, 2004 at 05:47 UTC |