blackgoat has asked for the wisdom of the Perl Monks concerning the following question:
Hi!
Pls help! My code is not working! Pls tell me whats wrong with it... it returns value 1 in all cases!!
%dbase = { apple => "fruit", brinjal => "vegetable" , coffee => "beverage", }; my @info; $info[0]="lemon"; $info[1]="juice"; $result = validate($info[0],$info[1]); sub validate { my $usr = @_[0]; my $pwd = @_[1]; while (($u, $p) = each %dbase) { if ($usr == $u && $pwd == $p) { return(1); break; } else { return(0); } } } {print "$result"};
Thanks
BG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sub always returns 1
by ikegami (Patriarch) on Mar 04, 2010 at 06:13 UTC | |
by blackgoat (Acolyte) on Mar 04, 2010 at 06:40 UTC | |
|
Re: sub always returns 1
by ungalnanban (Pilgrim) on Mar 04, 2010 at 06:54 UTC | |
|
Re: sub always returns 1
by Anonymous Monk on Mar 04, 2010 at 06:13 UTC | |
by MidLifeXis (Monsignor) on Mar 04, 2010 at 14:42 UTC |