in reply to error message in the end of the array looping?
You need the string equality op, 'eq', not assignment, '='. You can keep track of how many matches you have by incrementing a variable in the true branch. As it's written, the else branch is unnecessary; control goes to the next iteration anyway.
my $counter; for (@array) { if ($hash{$_} eq "correct_value") { $counter++ print "$_ Success\n"; last; } } print 'We have a match.', $/ if $counter;
Update: Albannach++ quickly spotted an error, repaired.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: error message in the end of the array looping?
by polettix (Vicar) on May 30, 2006 at 10:42 UTC | |
by Zaxo (Archbishop) on May 30, 2006 at 10:51 UTC |