my $raw_data = uri_unescape $query->param('data'); my $api_key = uri_unescape $query->param('api_key'); $sth = $user_dbh->prepare($get_secret_key); $sth->execute($user_id); my ($secret_key) = $sth->fetchrow_array() and $sth->finish(); ... if($api_key eq hmac_sha512_hex($raw_data.$xyz.$abc,$secret_key)) { $auth_services{$service}->(); }else{ $status_ref->{'status'} = "FAIL"; $status_ref->{'status_cd'} = "F"; $status_ref->{'message'} = "Login details unable to be confirmed"; $status_ref->{'response_cd'} = "401"; }