Your issue is that you are using subroutine
Prototypes in defining
_validate. Prototypes can only be applied when the subroutine is defined prior to usage, so the order affects whether the compiler tests prototypes or not. Since you are not actually using them (and if you were, using them incorrectly), your sub definition should read:
sub _validate{
my ($login) = @_;
if(($login->{uname} eq 'rajiv') && ($login->{pwd} eq 'rajiv')) {
print "Login success";
}
else {
print "Login failed";
}
}