Pls help! My code is not working! Pls tell me whats wrong with it... it returns value 1 in all cases!!
Expand|Select|Wrap|Line Numbers
- %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"};
BG