Created
February 5, 2018 19:27
-
-
Save levlaz/c8d738318d06cdacabb0ad6bedd14c62 to your computer and use it in GitHub Desktop.
LD Perl Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
sub ShowFeature { | |
my ($key, $user) = @_; | |
ld_eval($key, $user); | |
}; | |
my $user = '{"key": "[email protected]"}'; | |
my $key = 'new-search-algorithm'; | |
if (ShowFeature($key, $user)) { | |
print "Showing Feature\n"; | |
} else { | |
print "Not Showing Feature\n"; | |
} | |
use Inline Python => <<'END_OF_PYTHON_CODE'; | |
import ldclient | |
import json | |
ldclient.set_sdk_key("$YOUR_SDK_KEY") | |
ld_client = ldclient.get() | |
def ld_eval(key, user, default=False): | |
print("Evaluating {0} for {1}".format(key, user)) | |
return ld_client.variation(key.decode("utf-8") , json.loads | |
(user), default) | |
END_OF_PYTHON_CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment