Skip to content

Instantly share code, notes, and snippets.

@levlaz
Created February 5, 2018 19:27
Show Gist options
  • Save levlaz/c8d738318d06cdacabb0ad6bedd14c62 to your computer and use it in GitHub Desktop.
Save levlaz/c8d738318d06cdacabb0ad6bedd14c62 to your computer and use it in GitHub Desktop.
LD Perl Example
#!/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